1. ls – List Directory Contents
The ls command is used to list the contents of a directory. Here are some example usages:
ls: List files and directories in the current directory.ls /path/to/directory: List files and directories in the specified directory.
2. cd – Change Directory
The cd command is used to change the current working directory. Example usage:
cd /path/to/directory: Change the current directory to the specified directory.
3. pwd – Print Working Directory
The pwd command prints the current working directory. Example usage:
pwd: Print the current working directory.
4. mkdir – Make Directory
The mkdir command is used to create directories. Example usage:
mkdir directory_name: Create a directory with the specified name.
5. rm – Remove
The rm command is used to remove files and directories. Example usage:
rm file_name: Remove the specified file.rm -r directory_name: Remove the specified directory and its contents recursively.
6. cp – Copy
The cp command is used to copy files and directories. Example usage:
cp file1 file2: Copyfile1tofile2.cp -r directory1 directory2: Copydirectory1and its contents recursively todirectory2.
7. mv – Move
The mv command is used to move or rename files and directories. Example usage:
mv file1 file2: Movefile1tofile2or renamefile1tofile2.mv file1 /path/to/directory: Movefile1to the specified directory.
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:
touch file_name: Create an empty file with the specified name.
9. cat – Concatenate and Display
The cat command is used to concatenate files and display their contents. Example usage:
cat file1 file2: Concatenate and display the contents offile1andfile2.cat file_name: Display the contents of the specified file.
10. nano – Text Editor
The nano command is a simple text editor used for editing files in the terminal. Example usage:
nano file_name: Open the specified file in the nano text editor.
11. grep – Search
The grep command is used to search for patterns in text files. Example usage:
grep pattern file_name: Search for the specified pattern in the specified file.grep -r pattern directory: Search for the specified pattern recursively in the specified directory.
12. sudo – Superuser Do
The sudo command is used to execute commands with superuser privileges. Example usage:
sudo command: Execute the specified command with superuser privileges.
13. apt-get – Package Manager
The apt-get command is used to manage packages on Ubuntu. Example usage:
sudo apt-get update: Update the package lists for available upgrades.sudo apt-get install package_name: Install the specified package.sudo apt-get remove package_name: Remove the specified package.
14. dpkg – Package Manager
The dpkg command is used to install, remove, and manage individual packages. Example usage:
sudo dpkg -i package_file.deb: Install the specified package from a .deb file.sudo dpkg -r package_name: Remove the specified package.
15. chmod – Change Mode
The chmod command is used to change the permissions of files and directories. Example usage:
chmod permissions file_name: Change the permissions of the specified file.chmod permissions directory_name: Change the permissions of the specified directory.
16. chown – Change Owner
The chown command is used to change the owner of files and directories. Example usage:
chown new_owner file_name: Change the owner of the specified file.chown new_owner:new_group file_name: Change the owner and group of the specified file.
17. tar – Tape Archive
The tar command is used to archive and extract files. Example usage:
tar -cvf archive_name.tar files: Create a new archive file.tar -xvf archive_name.tar: Extract files from an archive.
18. uname – Print System Information
The uname command prints system information. Example usage:
uname -a: Print all system information.uname -r: Print the kernel release.
19. date – Display Date and Time
The date command is used to display the current date and time. Example usage:
date: Display the current date and time.date "+%Y-%m-%d": Display the current date in YYYY-MM-DD format.
20. shutdown – Shutdown or Restart System
The shutdown command is used to shutdown or restart the system. Example usage:
sudo shutdown now: Shutdown the system immediately.sudo shutdown -r now: Restart the system immediately.
21. ps – Process Status
The ps command is used to display information about active processes. Example usage:
ps: Display information about active processes.ps aux | grep process_name: Display information about processes matching the specified name.
22. top – Display System Activity
The top command is used to display real-time system activity. Example usage:
top: Display real-time system activity.top -u username: Display system activity for the specified user.
23. du – Disk Usage
The du command is used to display disk usage. Example usage:
du: Display disk usage of the current directory.du -h: Display disk usage in human-readable format.
24. df – Disk Free
The df command is used to display disk space usage. Example usage:
df: Display disk space usage of all mounted filesystems.df -h: Display disk space usage in human-readable format.
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:
/mnt/phd– for system-wide use/home/yourname/phd_drive– for personal use
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
yourusername with your actual Linux username.
Using /media/saurabh/PhD as Mount Point
You can use it, but it’s not recommended. Issues include:
- May not exist at boot time
- Can conflict with desktop auto-mounters
- May auto-unmount on logout
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
/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
-s: create a symbolic (soft) link instead of a hard link-f: force overwrite if the link name already exists
📎 Hard Link vs Symbolic Link
- Hard link: another name for the same file (not recommended for directories)
- Symbolic link: points to the file path (can span partitions and directories)
🧹 How to Remove a Symlink
To remove:
rm <link_name>
This only deletes the link, not the original file or directory.
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.