Essential System Administrator Commands in Ubuntu

Mastering the command line for efficient system administration

1. ls – List Directory Contents

The ls command is used to list the contents of a directory. Here are some example usages:

2. cd – Change Directory

The cd command is used to change the current working directory. Example usage:

3. pwd – Print Working Directory

The pwd command prints the current working directory. Example usage:

4. mkdir – Make Directory

The mkdir command is used to create directories. Example usage:

5. rm – Remove

The rm command is used to remove files and directories. Example usage:

6. cp – Copy

The cp command is used to copy files and directories. Example usage:

7. mv – Move

The mv command is used to move or rename files and directories. Example usage:

8. touch – Create Empty File

The touch command is used to create an empty file or update the timestamp of an existing file. Example usage:

9. cat – Concatenate and Display

The cat command is used to concatenate files and display their contents. Example usage:

10. nano – Text Editor

The nano command is a simple text editor used for editing files in the terminal. Example usage:

11. grep – Search

The grep command is used to search for patterns in text files. Example usage:

12. sudo – Superuser Do

The sudo command is used to execute commands with superuser privileges. Example usage:

13. apt-get – Package Manager

The apt-get command is used to manage packages on Ubuntu. Example usage:

14. dpkg – Package Manager

The dpkg command is used to install, remove, and manage individual packages. Example usage:

15. chmod – Change Mode

The chmod command is used to change the permissions of files and directories. Example usage:

16. chown – Change Owner

The chown command is used to change the owner of files and directories. Example usage:

17. tar – Tape Archive

The tar command is used to archive and extract files. Example usage:

18. uname – Print System Information

The uname command prints system information. Example usage:

19. date – Display Date and Time

The date command is used to display the current date and time. Example usage:

20. shutdown – Shutdown or Restart System

The shutdown command is used to shutdown or restart the system. Example usage:

21. ps – Process Status

The ps command is used to display information about active processes. Example usage:

22. top – Display System Activity

The top command is used to display real-time system activity. Example usage:

23. du – Disk Usage

The du command is used to display disk usage. Example usage:

24. df – Disk Free

The df command is used to display disk space usage. Example usage:

Automatically Mount a Linux Partition at Boot

Step 1: Identify the Partition UUID

Run the following command in the terminal to get the UUID of your partition:

lsblk -f

Example output:

nvme0n1p5 ext4   PhD  f0e5cddf-907a-4670-880e-2ee175bd1588  ...  /media/saurabh/PhD
  

Step 2: Choose a Mount Point

Recommended options:

sudo mkdir -p /mnt/phd

Step 3: Add to /etc/fstab

Edit the /etc/fstab file:

sudo nano /etc/fstab

Add the following line at the end:

UUID=f0e5cddf-907a-4670-880e-2ee175bd1588  /mnt/phd  ext4  defaults  0  2

Step 4: Test the Configuration

sudo mount -a

If no errors occur, it's working!

Step 5: Set Ownership (Optional)

Give your user access to the mount point:

sudo chown yourusername:yourusername /mnt/phd
Note: Replace yourusername with your actual Linux username.

Using /media/saurabh/PhD as Mount Point

You can use it, but it’s not recommended. Issues include:

If you still want to use it:

sudo mkdir -p /media/saurabh/PhD
sudo chown saurabh:saurabh /media/saurabh/PhD
# Add this to /etc/fstab instead:
UUID=f0e5cddf-907a-4670-880e-2ee175bd1588  /media/saurabh/PhD  ext4  defaults  0  2
  
Best Practice: Use /mnt or /home/yourname for internal, permanent partitions.

Understanding Symbolic Links in Linux

🔗 What is a Symbolic Link?

A symbolic link (or symlink) is like a shortcut or alias to another file or directory. It allows access to files across different locations without duplicating data.

📂 Example Use Case

You started Jupyter Lab in ~/Downloads, but want to access files in ~/Documents. Create a symlink:

ln -s ~/Documents ~/Downloads/my_docs

This creates a folder my_docs inside Downloads that points to Documents.

📌 How to Create a Symlink

Basic syntax:

ln -s <target_path> <link_name>

Example:

ln -s /home/saurabh/PhD /mnt/phd

✅ Confirm the Link

ls -l

Output:

lrwxrwxrwx 1 saurabh saurabh  12 May 19 11:11 phd -> /home/saurabh/PhD

🛠 Common Options

📎 Hard Link vs Symbolic Link

Tip: Use symbolic links when working across partitions, or when directory layout should stay clean.

🧹 How to Remove a Symlink

To remove:

rm <link_name>

This only deletes the link, not the original file or directory.

⚠️ Warning: Do not use rm -r on symlinks to directories — it may delete the actual content.

📁 Jupyter Lab Tip

To access ~/PhD in Jupyter Lab started in ~/Downloads:

ln -s ~/PhD ~/Downloads/phd_link

Now Jupyter can access the phd_link as if it were inside Downloads.