Linux is an open-source, Unix-like operating system (OS) kernel that serves as the foundation for various operating system distributions (distros). It was created by Linus Torvalds in 1991 and has since become one of the most widely used OS kernels in the world.
Here are some essential Linux commands that every user should know:
ls
– List directory contents
ls -l # Long format
ls -a # Show hidden files
cd
– Change directory
cd /home/user/Documents
pwd
– Print working directory
pwd
mkdir
– Create a new directory
mkdir myfolder
rmdir
– Remove an empty directory
rmdir myfolder
rm
– Remove files or directories
rm file.txt
rm -r myfolder # Remove a directory and its contents
cp
– Copy files or directories
cp file.txt /destination/
cp -r dir1/ dir2/ # Copy directories
mv
– Move or rename files
mv oldname.txt newname.txt
mv file.txt /new/location/
cat
– View file contents
cat file.txt
less
– View file contents page by page
less file.txt
head
– Show the first 10 lines of a file
head file.txt
tail
– Show the last 10 lines of a file
tail file.txt
tail -f log.txt # Continuously display new lines
nano
– Simple text editor
nano file.txt
vi
or vim
– Advanced text editor
vi file.txt
chmod
– Change file permissions
chmod 755 script.sh
chmod u+x script.sh # Give execute permission to the user
chown
– Change file owner
chown user:group file.txt
ps
– Display running processes
ps aux
top
– Show system resource usage
top
htop
– Interactive process viewer (if installed)
htop
kill
– Terminate a process
kill PID
kill -9 PID # Force kill a process
df
– Show disk usage
df -h
du
– Show directory size
du -sh foldername
whoami
– Show current user
whoami
who
– Show logged-in users
who
id
– Show user ID and group ID
id
passwd
– Change user password
passwd
su
– Switch user
su username
sudo
– Run command as superuser
sudo apt update
ip a
– Show IP addresses
ip a
ping
– Check network connectivity
ping google.com
netstat
– Show network connections (deprecated, use ss
)
netstat -tulnp
ss
– Display network connections
ss -tulnp
wget
– Download files from the internet
wget https://example.com/file.zip
For Debian-based systems (Ubuntu, Debian):
apt update
– Update package lists
sudo apt update
apt upgrade
– Upgrade all packages
sudo apt upgrade
apt install
– Install a package
sudo apt install package-name
apt remove
– Remove a package
sudo apt remove package-name
For RHEL-based systems (CentOS, Fedora):
yum update
– Update package lists
sudo yum update
yum install
– Install a package
sudo yum install package-name
tar
– Create or extract compressed archives
tar -cvf archive.tar foldername # Create tar archive
tar -xvf archive.tar # Extract tar archive
tar -czvf archive.tar.gz foldername # Create gzipped tar archive
tar -xzvf archive.tar.gz # Extract gzipped tar archive
zip
– Compress files into a .zip archive
zip -r archive.zip foldername
unzip
– Extract .zip files
unzip archive.zip
find
– Search for files and directories
find /path -name "file.txt"
grep
– Search inside files
grep "text" file.txt
grep -r "text" /directory/
uname -a
– Show system informationuptime
– Show system uptimefree -h
– Show memory usagehistory
– Show command historyclear
– Clear terminal screen.