0% found this document useful (0 votes)
3 views

Linux Basic Commands

This document provides a comprehensive list of basic Linux commands categorized into sections such as Basic Commands, File Operations, Permissions and Ownership, Disk and Directory Management, System Monitoring, Networking, Archiving and Compression, and System Information. Each command is accompanied by a brief description and an example of its usage. It serves as a quick reference guide for users to navigate and manage a Linux environment effectively.

Uploaded by

Devender Baghel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Linux Basic Commands

This document provides a comprehensive list of basic Linux commands categorized into sections such as Basic Commands, File Operations, Permissions and Ownership, Disk and Directory Management, System Monitoring, Networking, Archiving and Compression, and System Information. Each command is accompanied by a brief description and an example of its usage. It serves as a quick reference guide for users to navigate and manage a Linux environment effectively.

Uploaded by

Devender Baghel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Mayank Singh

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

16. find [path] -name [filename]


Searches for files by name.

find /home -name "*.txt"


17. grep [pattern] [file]
Searches for a pattern in a file.

grep "error" log.txt


18. diff [file1] [file2]
Compares two files line by line.

diff file1.txt file2.txt


19. sort [file]
Sorts the contents of a file.

sort names.txt
20. uniq [file]
Removes duplicate lines from a file.

uniq sorted_names.txt

Permissions and Ownership


Mayank Singh

21. chmod [permissions] [file]


Changes file permissions.

chmod 755 script.sh


22. chown [user:group] [file]
Changes file ownership.

chown user:group file.txt


23. umask
Displays or sets default permissions.

umask 022
24. stat [file]
Displays detailed file information.

stat file.txt
25. ls -l
Lists files with detailed permissions.

ls -l

Disk and Directory Management


Mayank Singh

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.

mount /dev/sdb1 /mnt


29. umount [directory]
Unmounts 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

36. ping [hostname/IP]


Tests network connectivity.

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

Archiving and Compression


Mayank Singh

41. tar -cvf [archive.tar] [files]


Creates a tar archive.

tar -cvf archive.tar file1 file2


42. tar -xvf [archive.tar]
Extracts a tar archive.

tar -xvf archive.tar


43. gzip [file]
Compresses a file.

gzip file.txt
44. gunzip [file.gz]
Decompresses a file.

gunzip file.txt.gz
45. zip [archive.zip] [files]
Creates a zip archive.

zip archive.zip file1 file2


46. unzip [archive.zip]
Extracts a zip archive.
Mayank Singh

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

You might also like