Linux is a powerful operating system widely used for its flexibility, performance, and the robust command-line interface (CLI) it offers. This article demonstrates practical usage of Linux commands through a terminal session that showcases file management, system utilities, permissions, and directory navigation.
1. File Management Commands
Creating Files
The touch
command is used to create empty files or update the timestamp of existing files:
touch file1 # Creates file1
touch file1 file2 file3 # Creates file1, file2, and file3
Viewing File Content
The cat
command displays the contents of a file:
cat file1 # Displays the content of file1
Listing Files
The ls
command lists the contents of the current directory:
ls # Displays all files and directories
2. Directory Management
Creating Directories
The mkdir
command creates new directories. You can create multiple directories simultaneously:
mkdir folder1 # Creates folder1
mkdir folder1 folder2 folder3 # Creates folder1, folder2, and folder3
Navigating Directories
Use cd
to change directories and pwd
to display the current working directory:
cd folder1/ # Moves into folder1
pwd # Prints the current directory
cd .. # Moves one level up in the directory tree
3. System Utilities
Checking Time, Date, and Calendar
Linux provides built-in utilities to check system time and date:
time # Displays the current system time
date # Displays the current system date
cal # Displays the current month's calendar
cal 12 2024 # Displays the calendar for December 2024
cal 1 2025 # Displays the calendar for January 2025
cal 2030 # Displays the calendar for the year 2030
Installing Software
Using package managers like apt
, you can install software:
sudo apt-get update # Updates the package list
sudo apt install ncal # Installs the ncal command
sudo apt install git # Installs Git
git --version # Checks the installed version of Git
4. File and Directory Operations with sudo
Managing Files and Directories
With elevated privileges (sudo
), you can perform operations requiring administrative permissions:
sudo mkdir p1 p2 p3 # Creates directories p1, p2, and p3
sudo touch f1 f2 f3 # Creates files f1, f2, and f3
sudo cp /opt/f1 /home/ubuntu/folder1/ # Copies f1 to folder1
sudo mv /opt/p1 /home/ubuntu/folder1/ # Moves p1 to folder1
sudo cp -r /opt/* /home/ubuntu/folder2/ # Recursively copies all files from /opt to folder2
5. System Navigation and Information
Exploring Directories
You can navigate system directories to explore their contents:
cd /etc/ # Moves to the /etc directory
cd /opt/ # Moves to the /opt directory
ls # Lists the contents of the current directory
Checking Active Users
The who
command displays information about currently logged-in users:
who # Lists logged-in users and their login details
6. Reviewing Command History
The history
command provides a list of previously executed commands:
history # Displays a list of commands with their respective numbers
This is useful for auditing or reusing past commands.
Conclusion
The Linux CLI is a versatile tool for managing files, directories, and system utilities. By mastering these commands, you can enhance your productivity and gain deeper control over your system. Practice is key—open your terminal and try these commands to see them in action!
If you have any queries or need further assistance, feel free to contact us:
📧 Email: devopsbyrushi@gmail.com
🌐 Website: www.rushiinfotech.in
We’re here to help you with all your Linux-related questions! 😊