Introduction
Linux commands are the building blocks for managing and interacting with the Linux operating system. Whether you’re a seasoned system administrator or a beginner exploring the world of Linux, understanding these essential commands is crucial. In this article, we’ll delve into 50 important Linux commands, complete with practical examples to help you grasp their utility.
Note: Be cautious when running commands with administrative privileges (e.g., sudo
) to avoid making unintended changes to your system.
commands
ls - List files and directories.
ls /home/user/documents
cd - Change the current directory.
cd /var/www/html
pwd - Print the current working directory.
pwd
mkdir - Create a new directory.
mkdir new_directory
rmdir - Remove an empty directory.
rmdir empty_directory
touch - Create a new empty file or update a file’s timestamp.
touch new_file.txt
rm - Remove files or directories.
rm file.txt rm -r directory/
cp - Copy files and directories.
cp file.txt new_directory/
mv - Move or rename files and directories.
mv file.txt new_name.txt
cat - Concatenate and display file content.
cat file.txt
more and less - View file content page by page.
more file.txt less large_file.log
head and tail - Display the beginning or end of a file.
head file.txt tail log_file.log
nano and vim - Text editors for creating and editing files.
nano new_file.txt vim existing_file.txt
grep - Search for patterns in files.
grep "pattern" file.txt
find - Search for files and directories.
find /home/user -name "*.txt"
chmod - Change file permissions.
chmod 644 file.txt
chown - Change file ownership.
chown user:group file.txt
df - Display disk space usage.
df -h
du - Display file and directory space usage.
du -sh /var
top and htop - Monitor system processes.
top htop
ps - Display information about running processes.
ps aux
kill - Terminate processes.
kill process_id
ping - Check network connectivity.
ping google.com
ifconfig and ip - Network configuration tools.
ifconfig ip addr show
ssh - Securely connect to remote servers.
ssh user@remote_server
scp - Securely copy files between systems.
scp file.txt user@remote_server:/path/to/destination/
tar - Archive and compress files.
tar -cvzf archive.tar.gz directory/
gzip and gunzip - Compress and decompress files.
gzip file.txt gunzip file.txt.gz
wget and curl - Download files from the internet.
wget https://example.com/file.zip curl -O https://example.com/image.jpg
date - Display or set the system date and time.
date date -s "2023-09-04 14:30:00"
cal - Display a calendar.
cal
history - View command history.
history
alias - Create shortcut commands.
alias ll='ls -al'
sudo - Execute commands with superuser privileges.
sudo apt update
passwd - Change user password.
passwd
useradd and userdel - Add and delete user accounts.
sudo useradd newuser sudo userdel olduser
groupadd and groupdel - Manage user groups.
sudo groupadd mygroup sudo groupdel mygroup
shutdown and reboot - Shutdown or restart the system.
sudo shutdown -h now sudo reboot
df - Display disk space usage.
df -h
du - Display file and directory space usage.
du -sh /var
quota - Manage disk quotas for users.
quota -u user
scp - Securely copy files between systems.
scp file.txt user@remote_server:/path/to/destination/
dd - Copy and convert files.
dd if=input_file of=output_file bs=4M
lsof - List open files and processes.
lsof -i :80
nc - Network utility for reading from and writing to network connections.
nc -l -p 12345
at and cron - Schedule tasks.
at now + 1 hour crontab -e
killall - Terminate processes by name.
killall process_name
mount and umount - Mount and unmount file systems.
mount /dev/sdX1 /mnt umount /mnt
fdisk and parted - Partition management tools.
fdisk -l parted /dev/sdX
Conclusion
These 50 essential Linux commands form the foundation of your Linux journey. By mastering these commands and understanding their usage through practical examples, you’ll be better equipped to manage your Linux system efficiently, troubleshoot issues, and perform various tasks with ease. Continue to explore and experiment with these commands to unlock the full potential of Linux.