List of Basic Linux Commands
Hello guys, I would like to share with you list of some Linux basic commands that might be of help to beginners.
Note: Add a sudo before writing the command, which will give you root access and higher privileges. Or it is called the super user. This is similar to the “Admin” access in Windows.
Append text to a file
echo “content” >>
Overwrite a file’s content
echo “content” >
Redirect (append) standard output to a file
ls -la >>
View resources being used on your system
top
View who is logged on
who
View used and available disk space
df -h
Clear a command line screen
clear
Start a service
service start
Stop a service
service stop
Restart a service
service restart
View the content of a file
cat
View the last 10 lines of a file’s content
tail -10
View the first 10 lines of a file’s content
head -10
Force termination of a process
kill -9 pid
Delete an empty directory
rmdir
Create an empty file
touch
Change the password of an user
passwd
View a snapshot of the currently running processes
ps x
Compress a file in .tar.gz
tar czf compressed.tar.gz
Compress a file in .tar
tar cf compressed.tar
Decompress a .gz file
gunzip
Decompress a .tar file
tar xf
Change directory
cd
Update the package lists from the repositories
apt-get update
Install a new package
apt-get install
Completely remove an installed package
apt-get –purge autoremove
Update an already installed package
apt-get update && apt-get install
Get the current directory
pwd
View active connections
netstat -an
List directory content
ls -la
List block devices by their assigned name
lsblk
Get md5 checksum of a file
md5sum
View information about the machine name
uname -a
View history of executed commands in terminal
history
Clear recent hostory of executed commands
history -c
Create a new directory
mkdir
Change file permissions
chmod
Change the owner and group of a folder
chown www-data:www-data /var/directory
Change the owner and group of a folder recursively
chown -R www-data:www-data /var/directory
Remove a file
rm -f
Remove a folder (and files) recursively
rm -rf
Get current date and time
date
Copy a file from one location to another
cp
Move a file from one location to another
mv
Rename a file
mv
Let me know if this helps! Send your comments below 🙂
rm -R Lovelife/:P/