This documentation provides a comprehensive list of essential Linux commands, categorized for clarity and ease of reference. Whether you are new to Linux or an experienced user, this guide serves as a practical resource to improve your command-line skills.
Contributions are encouraged. If you would like to suggest additional commands or improvements, please submit a pull request.
- Introduction
- File and Directory Management
- Viewing and Editing Files
- User and Permission Management
- Process and System Management
- Networking Tools
- Package Management
- Compression and Archiving
- Disk and Filesystem Management
- Miscellaneous Commands
- Contributing
Linux is a versatile operating system widely used for development, server management, and system administration. Mastering the Linux command line interface (CLI) is essential for effective system operation and troubleshooting.
This documentation categorizes the most commonly used commands to help you navigate and use the Linux CLI efficiently.
π 2. File and Directory Management
ls- List files and directories.
Example:ls -la /var/www/htmlcd- Change the current directory.
Example:cd /home/user/Documentspwd- Display the current working directory.
Example: Output:/home/user/Projects
mkdir- Create a new directory.
Example:mkdir /home/user/Backuprmdir- Remove an empty directory.
Example:rmdir /home/user/OldFolderrm- Delete files or directories.
Example:rm -r /home/user/TempFiles
cp- Copy files or directories.
Example:cp /etc/nginx/nginx.conf /home/user/nginx_backup.confmv- Move or rename files/directories.
Example:mv /home/user/file.txt /home/user/Documents/file_renamed.txt
find- Search for files or directories.
Example:find /home/user -name "report.pdf"locate- Quickly locate files.
Example:locate settings.json
π 3. Viewing and Editing Files
cat- Display the content of a file.
Example:cat /etc/hostsless- View file content one page at a time.
Example:less /var/log/sysloghead- Show the first few lines of a file.
Example:head -n 5 /var/log/auth.logtail- Show the last few lines of a file.
Example:tail -f /var/log/apache2/access.log(for live monitoring).nano- Edit files in a simple text editor.
Example:nano /etc/fstabvim- Advanced text editor for editing files.
Example:vim /home/user/.bashrcsed- Stream editor for modifying file content.
Example:sed 's/old-word/new-word/g' /home/user/document.txt
π 4. User and Permission Management
whoami- Display the current user.
Example: Output:userid- Show user ID and group information.
Example:id useradduser- Add a new user.
Example:sudo adduser new_userpasswd- Change a user password.
Example:sudo passwd new_usersu- Switch to another user or root.
Example:su root
chmod- Change file or directory permissions.
Example:chmod 644 /var/www/html/index.htmlchown- Change file ownership.
Example:chown user:user /home/user/project
π 5. Process and System Management
ps- Display running processes.
Example:ps aux | grep nginxtop/htop- Monitor processes in real-time.kill- Terminate a process by its PID.
Example:kill 1234killall- Terminate all processes with a specific name.
Example:killall nginx
uptime- Show system uptime and load.df- Display available disk space.
Example:df -h /dev/sda1du- Display directory or file sizes.
Example:du -sh /home/user/Projects
π 6. Networking Tools
ping- Check connectivity to a host.
Example:ping 8.8.8.8curl- Fetch data from a URL.
Example:curl https://example.com/api/statuswget- Download files from a URL.
Example:wget https://example.com/file.zipifconfig/ip a- Display network interface information.ssh- Connect to a remote server securely.
Example:ssh user@192.168.1.10
π 7. Package Management
apt update- Refresh package lists.apt upgrade- Upgrade all installed packages.apt install- Install a specific package.
Example:sudo apt install gitapt remove- Remove an installed package.
Example:sudo apt remove apache2
dnf update- Update installed packages.dnf install- Install a package.
Example:sudo dnf install httpddnf remove- Remove a package.
Example:sudo dnf remove php
π 8. Compression and Archiving
tar- Create/extract tar archives.
Example:tar -czvf backup.tar.gz /home/user/Projectsgzip- Compress files.
Example:gzip /home/user/report.txtunzip- Extract ZIP files.
Example:unzip /home/user/archive.zip
π 9. Disk and Filesystem Management
mount- Mount a filesystem.
Example:sudo mount /dev/sdb1 /mnt/external_driveumount- Unmount a filesystem.
Example:sudo umount /mnt/external_drivefdisk- Partition management.
Example:sudo fdisk /dev/sdamkfs- Format a partition with a filesystem.
Example:mkfs.ext4 /dev/sdb1
π 10. Miscellaneous Commands
alias- Create command shortcuts.
Example:alias ll='ls -la'echo- Print text to the terminal.
Example:echo "Hello, world!"date- Display the current date and time.
Example:date "+%Y-%m-%d %H:%M:%S"history- View command history.
Example:history | grep sshclear- Clear the terminal screen.
Contributions are welcome. If you have additional commands to suggest or improvements to propose:
- Fork this repository.
- Make your changes.
- Submit a pull request with a clear description.