Linux Basic Commands
Linux Basic Commands
Basic Commands
1. pwd
Prints the current directory.
pwd
Output: /home/user
2. ls
Lists files and directories.
ls
Output: file1 file2 directory1
3. cd [directory]
Changes the directory.
cd /var/log
4. mkdir [directory]
Creates a new directory.
mkdir myfolder
5. rmdir [directory]
Removes an empty directory.
Mayank Singh
rmdir myfolder
6. rm [file/directory]
Deletes files or directories.
rm myfile.txt
rm -r myfolder
7. touch [file]
Creates an empty file or updates the timestamp.
touch newfile.txt
8. cp [source] [destination]
Copies files or directories.
cp file.txt /backup/
9. mv [source] [destination]
Moves or renames files.
mv oldname.txt newname.txt
10. cat [file]
Displays the content of a file.
cat file.txt
Mayank Singh
File Operations
11. nano [file]
Opens a file in Nano text editor.
nano file.txt
12. vim [file]
Opens a file in Vim text editor.
vim file.txt
13. head [file]
Displays the first 10 lines of a file.
head file.txt
14. tail [file]
Displays the last 10 lines of a file.
tail file.txt
15. wc [file]
Counts words, lines, and characters in a file.
wc file.txt
Mayank Singh
sort names.txt
20. uniq [file]
Removes duplicate lines from a file.
uniq sorted_names.txt
umask 022
24. stat [file]
Displays detailed file information.
stat file.txt
25. ls -l
Lists files with detailed permissions.
ls -l
26. df -h
Displays disk space usage in human-readable format.
df -h
27. du -h [directory]
Displays disk usage of a directory.
du -h /home
28. mount [device] [directory]
Mounts a filesystem.
umount /mnt
30. lsblk
Displays information about block devices.
lsblk
System Monitoring
Mayank Singh
31. top
Displays running processes and resource usage.
top
32. htop
Interactive process viewer.
htop
33. ps
Lists running processes.
ps aux
34. kill [PID]
Terminates a process by its PID.
kill 1234
35. uptime
Displays system uptime.
uptime
Networking
Mayank Singh
ping google.com
37. wget [URL]
Downloads files from the internet.
wget http://example.com/file.zip
38. curl [URL]
Fetches content from a URL.
curl http://example.com
39. ifconfig
Displays or configures network interfaces.
ifconfig
40. netstat -tuln
Displays active network connections.
netstat -tuln
gzip file.txt
44. gunzip [file.gz]
Decompresses a file.
gunzip file.txt.gz
45. zip [archive.zip] [files]
Creates a zip archive.
unzip archive.zip
System Information
47. uname -a
Displays system information.
uname -a
48. whoami
Displays the current user.
whoami
49. hostname
Displays the hostname.
hostname
50. history
Displays the history of commands.
history