Following presents a quick cheatsheet of some of the useful Linux commands. This is not an exhaustive list of Linux commands which ought to be remembered or mastered first, rather these are some of the most commonly used commands which we find ourselves entering at prompt more frequently than others.
Commands given here are based on MX Linux prompt, so almost all of them are useful in any Debian or Ubuntu flavored Linux.
To create a file:
touch hello.txt
To create multiple files:
touch {hello, world}.txt
To create a folder:
mkdir tutorials
To create parent folders too, if they do not already exist:
mkdir tutorials/python/django -p
To remove directory which is not empty:
rm -fr tutorials
To know the present directory location:
pwd
To change to home directory:
cd ~/
To know the space occupied by present directory:
du -h
To list the hidden files and folders:
ls -a
To list the details of each file and folder:
ls -l
To extract gz file:
tar -xvzf filename.gz
To extract bz2 file:
tar -xvjf filename.tar.bz2
To display the contents of a file (press q to exit):
less file.txt
To insert text into a file:
echo "Hello, World!" >> hello.txt
To know the overall system outlook (press q to exit):
top
To update and upgrade whole system:
sudo apt update && sudo apt upgrade
To completely remove an app:
sudo apt purge app_name
To remove the unused dependencies (cleaning up system of redundant packages):
sudo apt autoremove
To make a file (script) executable:
chmod +x installer.sh
To change the access permissions of files and folders (777 will give read, write and execute permissions to everyone):
sudo chmod -R 777 /var/www/html
To create a symbolic link of an executable and make it globally accessible:
sudo ln -s /home/my/lite-xl/lite-xl /usr/local/bin/lite-xl
To check the status of a service:
sudo service postgresql status
To stop a service:
sudo service postgresql stop
To disable firewall:
sudo ufw disable
To manage / switch between different installed versions of a runtime such as PHP:
sudo update-alternatives --config php