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/documentscd - Change the current directory.
cd /var/www/htmlpwd - Print the current working directory.
pwdmkdir - Create a new directory.
mkdir new_directoryrmdir - Remove an empty directory.
rmdir empty_directorytouch - Create a new empty file or update a file’s timestamp.
touch new_file.txtrm - 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.txtcat - Concatenate and display file content.
cat file.txtmore and less - View file content page by page.
more file.txt less large_file.loghead and tail - Display the beginning or end of a file.
head file.txt tail log_file.lognano and vim - Text editors for creating and editing files.
nano new_file.txt vim existing_file.txtgrep - Search for patterns in files.
grep "pattern" file.txtfind - Search for files and directories.
find /home/user -name "*.txt"chmod - Change file permissions.
chmod 644 file.txtchown - Change file ownership.
chown user:group file.txtdf - Display disk space usage.
df -hdu - Display file and directory space usage.
du -sh /vartop and htop - Monitor system processes.
top htopps - Display information about running processes.
ps auxkill - Terminate processes.
kill process_idping - Check network connectivity.
ping google.comifconfig and ip - Network configuration tools.
ifconfig ip addr showssh - Securely connect to remote servers.
ssh user@remote_serverscp - 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.gzwget and curl - Download files from the internet.
wget https://example.com/file.zip curl -O https://example.com/image.jpgdate - Display or set the system date and time.
date date -s "2023-09-04 14:30:00"cal - Display a calendar.
calhistory - View command history.
historyalias - Create shortcut commands.
alias ll='ls -al'sudo - Execute commands with superuser privileges.
sudo apt updatepasswd - Change user password.
passwduseradd and userdel - Add and delete user accounts.
sudo useradd newuser sudo userdel oldusergroupadd and groupdel - Manage user groups.
sudo groupadd mygroup sudo groupdel mygroupshutdown and reboot - Shutdown or restart the system.
sudo shutdown -h now sudo rebootdf - Display disk space usage.
df -hdu - Display file and directory space usage.
du -sh /varquota - Manage disk quotas for users.
quota -u userscp - 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=4Mlsof - List open files and processes.
lsof -i :80nc - Network utility for reading from and writing to network connections.
nc -l -p 12345at and cron - Schedule tasks.
at now + 1 hour crontab -ekillall - Terminate processes by name.
killall process_namemount and umount - Mount and unmount file systems.
mount /dev/sdX1 /mnt umount /mntfdisk 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.