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
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