Here's an easy-to-understand documentation for the listed Linux commands.
Directory Operations
1. ls
- List directories
ls
The most frequently used command in Linux to list the contents of a directory.
2. pwd
- Print working directory
pwd
Displays the current directory path.
3. cd
- Change directory
cd directory-name
Navigates to the specified directory.
4. mkdir
- Make directory
mkdir directory-name
Creates a new directory.
5. mv
- Move or rename files or directories
mv source destination
Moves or renames files or directories. If moving, it will transfer the file or directory to the new location. If renaming, it will change the name.
6. cp
- Copy files or directories
cp -r source destination
Copies files or directories. The -r
option allows copying of directories recursively.
7. rm
- Remove files or directories
rm file-name
rm -r directory-name
Deletes files or directories. Use the -r
option to remove directories recursively.
8. touch
- Create empty files
touch file-name
Creates a blank file if it does not already exist.
File Content and Display
9. cat
- Concatenate and display file content
cat file-name
Displays the contents of a file.
10. echo
- Display message
echo "your message"
Prints the provided message to the terminal.
11. less
- View file contents one page at a time
less file-name
Displays file content one page at a time, allowing for navigation.
12. head
- Display the first few lines of a file
head -n number-of-lines file-name
Shows the specified number of lines from the top of the file.
13. tail
- Display the last few lines of a file
tail -n number-of-lines file-name
Shows the specified number of lines from the bottom of the file.
System and User Information
14. uname
- System information
uname -a
Displays basic information about the operating system.
15. whoami
- Current username
whoami
Shows the active username.
Search and Compare
16. grep
- Search for a string in files
grep "search-string" file-name
Searches for a specified string within a file.
17. diff
- Compare files line by line
diff file1 file2
Displays the differences between two files.
18. cmp
- Compare two files byte by byte
cmp file1 file2
Checks if two files are identical.
19. comm
- Compare two sorted files line by line
comm file1 file2
Combines the functionalities of diff
and cmp
.
File Compression and Archiving
20. tar
- Archive files
tar -cvf archive-name.tar directory-name
tar -xvf archive-name.tar
Creates (-cvf
) or extracts (-xvf
) tar archives.
21. zip
- Compress files
zip archive-name.zip file1 file2
Compresses specified files into a zip archive.
22. unzip
- Decompress files
unzip archive-name.zip
Extracts files from a zip archive.
Process and System Management
23. ps
- Display active processes
ps aux
Lists all currently running processes.
24. kill
and killall
- Terminate processes
kill process-id
killall process-name
Terminates processes by their ID or name.
25. df
- Disk space usage
df -h
Displays disk space usage in a human-readable format.
Network Commands
26. ifconfig
- Network interface configuration
ifconfig
Displays network interfaces and IP addresses.
27. traceroute
- Trace network path
traceroute destination-address
Traces all network hops to reach the destination.
28. wget
- Download files from the internet
wget url
Downloads files from the specified URL.
Security and Permissions
29. chmod
- Change file permissions
chmod permissions file-name
Changes the permissions of a file.
30. chown
- Change file owner
chown owner:group file-name
Changes the ownership of a file.
31. sudo
- Execute command with superuser privileges
sudo command
Runs the command with elevated (superuser) privileges.
System Utilities
32. clear
- Clear terminal screen
clear
Clears the terminal display.
33. man
- Manual pages
man command
Accesses the manual pages for the specified command.
34. alias
- Create command shortcuts
alias new-command='existing-command'
Creates a custom shortcut for a regularly used command.
35. cal
- Display a calendar
cal
Displays a simple calendar in the terminal.
36. top
- Display active processes in real-time
top
Shows a real-time view of active processes and their system usage.
User Management
37. useradd
and usermod
- User management
sudo useradd username
sudo usermod -aG groupname username
Adds a new user or modifies an existing user.
38. passwd
- Update user passwords
passwd username
Creates or updates the password for a specified user.
Miscellaneous
39. ln
- Create symbolic links
ln -s target link-name
Creates a symbolic link to a target file or directory.
40. dd
- Data duplicator for creating bootable USBs
dd if=input-file of=/dev/sdX
Used for low-level copying and conversion of raw data.
41. export
- Set environment variables
export VARIABLE_NAME=value
Sets or exports environment variables.
42. whereis
- Locate binary, source, and manual pages for a command
whereis command
Finds the location of the binary, source, and manual pages for the specified command.
43. whatis
- Display a one-line description of a command
whatis command
Directory and File Operations
44. basename
- Extract the base name of a file or directory
basename /path/to/file
Prints the file name without the directory path.
45. dirname
- Extract the directory path of a file
dirname /path/to/file
Prints the directory path without the file name.
46. find
- Search for files in a directory hierarchy
find /path -name "filename"
Searches for files and directories within a specified path.
File Content and Manipulation
47. awk
- Pattern scanning and processing language
awk '{print $1}' file
Processes and analyzes text files, often used for extracting specific fields from text.
48. sed
- Stream editor for filtering and transforming text
sed 's/old-text/new-text/' file
Performs basic text transformations on an input stream (file or input from a pipeline).
System and User Information
49. uptime
- Show how long the system has been running
uptime
Displays the current time, how long the system has been running, and system load averages.
50. who
- Show who is logged on
who
Displays a list of users currently logged into the system.
51. last
- Show a listing of last logged-in users
last
Displays a list of users logged in and out since the log file was created.
Network Commands
52. ping
- Send ICMP ECHO_REQUEST to network hosts
ping host
Sends packets to a network host to test connectivity.
53. netstat
- Network statistics
netstat -tuln
Displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
54. curl
- Transfer data from or to a server
curl -O url
Transfers data from or to a server using various protocols (HTTP, FTP, etc.).
System Management
55. htop
- Interactive process viewer
htop
Displays an interactive view of system processes and their resource usage.
56. systemctl
- Control the systemd system and service manager
systemctl start|stop|restart|status service-name
Manages services and the system state.
Package Management
57. apt
- Package management for Debian-based distributions
sudo apt update
sudo apt install package-name
Updates package lists and installs packages on Debian-based systems.
58. yum
- Package management for Red Hat-based distributions
sudo yum update
sudo yum install package-name
Updates package lists and installs packages on Red Hat-based systems.
59. pacman
- Package management for Arch-based distributions
sudo pacman -Syu
sudo pacman -S package-name
Updates package lists and installs packages on Arch-based systems.
Miscellaneous
60. nc
(netcat) - Network troubleshooting and debugging tool
nc -zv host port
Checks the connectivity to a host on a specified port.
61. scp
- Secure copy (remote file copy program)
scp source-file user@remote-host:/path/to/destination
Copies files between hosts on a network.
62. rsync
- Remote file and directory synchronization
rsync -avz source destination
Synchronizes files and directories between two locations over a network.
63. crontab
- Schedule periodic jobs
crontab -e
Edits the crontab file to schedule periodic tasks.
64. at
- Schedule commands to run at a specific time
at time
Schedules a command to run at a specified time.
65. hostname
- Show or set the system's hostname
hostname
Displays or temporarily sets the system's hostname.
66. df
- Disk space usage of file systems
df -h
Shows the disk space usage of file systems in a human-readable format.
67. du
- Disk usage of files and directories
du -sh directory-name
Displays the disk usage of a specified directory.
68. history
- Show command history
history
Lists the command history for the current session.
69. watch
- Execute a program periodically, showing output fullscreen
watch -n interval command
Runs a specified command at regular intervals and displays the output.
70. xargs
- Build and execute command lines from standard input
echo 'arguments' | xargs command
These commands further enhance your ability to manage and navigate a Linux system effectively.
Top comments (1)
This is a nice start, but it could be better.
directory-path would be better than directory-name
touch modifies timestamps. Creating an empty file is a useful side effect
rm -r path only succeeds if path is empty (doesn't contain other files)
pkill should be included
find can use any starting path. It does not need to start at root. Starting at root takes a lot longer and often produces a lot of warning messages from trying to examine directories which do not have user level read access
dd is used for lots of things other than creating image files