ls | Lists files and directories in the current directory. | ls -l (detailed listing) |
mkdir | Creates a new directory. | mkdir newdir |
touch | Creates an empty file or updates the timestamp of an existing file. | touch file.txt |
echo | Displays text or variables, or writes to a file. | echo "Hello" > file.txt |
cat | Displays the contents of a file. | cat file.txt |
vim | Opens a file in the Vim text editor. | vim file.txt |
nano | Opens a file in the Nano text editor (user-friendly alternative to Vim). | nano file.txt |
rm | Removes a file. | rm file.txt |
rm -f | Forcibly removes a file without confirmation. | rm -f file.txt |
rm -rf | Recursively and forcibly removes directories and their contents. | rm -rf folder |
uname | Displays system information. | uname -a (detailed system info) |
whoami | Displays the current logged-in user. | whoami |
uptime | Shows how long the system has been running and system load averages. | uptime |
df | Shows disk space usage of the file systems. | df -h (human-readable format) |
du | Shows disk usage of files and directories. | du -sh folder (summary for folder) |
useradd | Adds a new user to the system. | sudo useradd newuser |
groupadd | Adds a new group to the system. | sudo groupadd newgroup |
userdel | Deletes a user from the system. | sudo userdel olduser |
groupdel | Deletes a group from the system. | sudo groupdel oldgroup |
chmod | Changes file or directory permissions. | chmod 755 file.txt (sets read/write/execute permissions) |
chown | Changes the owner of a file or directory. | sudo chown user:group file.txt |
passwd | Changes a user's password. | passwd |
cp | Copies files or directories. | cp file1.txt file2.txt |
mv | Moves or renames files or directories. | mv file1.txt newfolder/ |
date | Displays or sets the system date and time. | date |
top | Shows real-time system processes and resource usage. | top |
ps | Displays a snapshot of currently running processes. | ps aux (detailed list of processes) |
grep | Searches for patterns in files or output. | grep "text" file.txt |
wc | Counts lines, words, and characters in a file. | wc -l file.txt (counts lines) |
watch | Runs a command repeatedly, showing its output in real-time. | watch df -h (shows disk usage every 2 seconds) |
history | Shows the command history of the current session. | history |
man | Displays the manual for a command. | man ls |
which | Shows the location of a command in the system's PATH. | which ls |