SOME ESSENTIAL TERMINAL COMMANDS


The Terminal/CLI [Command-Line Interface] allows the user to have a finer degree of control over the computer. The aim of this post is to introduce the reader to the most bare-bones of the linux-commands that you might need to know IF YOU EVER decide to try out the terminal [AKA the CLI which stands for the "Command-Line-Interface"]

SHORTCUT = CTRL+ALT+t or ALT+CTRL+t is the most common


Here are some Basic Terminology to keep in mind:-

BASIC COMMANDS

COMMANDS DESCRIPTIONS
COMMAND --help Displays some Quick-Help info about using that particlar COMMAND [Like "cd", "sudo" etc....]
man COMMAND
man man
Displays a detailed manual about that specific COMMAND
Displays a detailed manual about the man-COMMAND
cd DIRECTORY-NAME
cd ..
cd ~
cd /
Navigates to the Directory you specified
Navigates to the previous Directory
Switches to the HOME-Directory
Switches to the ROOT-Directory
pwd Displays your current Directory [Including the path to your current directory]
tree DIRECTORY-NAME Display the contents of the specified directory in a "Tree-View" [You may need to install the "tree"-programme]
mkdir DIRECTORY-NAME Creates a Directory with the specified NAME
rmdir DIRECTORY-NAME Removes a Directory with the specified NAME [Provided it is empty]
ls
ls -l
ls -a
ls -al
Lists out the files & directories in your current directory [You can also specify directory names to check for diectories with in them]
Lists out the files & directories in your current directory with extra-info about it
Lists out all the files & directories in your current directory, including the hidden files & directories
Lists out all the files & directories in your current directory, including the hidden files & directories & with extra-info about it
touch FILE-NAME Creates a file with the specified name
rm FILE-NAME
rm -r DIRECTORY-NAME
rm -rf FILE/DIRECTORY-NAME
Removes a File with the specified name
Removes a Directory with the specified NAME along with the files within it ["r" = recursive]
Removes a File/Directory with the specified NAME along with the files within it, no matter what [Reminder, "f" = force; So use it Wisely]
cp FILE-NAME LOCATION Copies a file to a specified Location
mv FILE-NAME LOCATION Moves a file to a specified Location/Rename the file [You can only rename if you move the file to the location with a different name]
cat Displays the contents of the file
sudo
sudo su
sudo !!
Grants you "Elevated Priviledges" temporarily [AKA a "SuperUser" or "Administrator"]
Switches to ROOT-USER/SUPERUSER-Mode
Re-Runs the previous command with SUDO-PRIVILEDGES [SUDO means SuperUser DO]
clear Clears the terminal window
exit Closes the terminal

ADVANCED COMMANDS

Now these command are "Nice-To-Know" & will basically give you more power/convenience when using the terminal :-)


COMMANDS DESCRIPTIONS
chmod +x FILE-NAME
chmod -x FILE-NAME
Grants "Execute-Permission" to files [Especially; to Shell-Scripts]
Removes "Execute-Permission" to files [Especially; to Shell-Scripts]
./SCRIPT-NAME Executes Shell-Scripts [You can also simple input the SCRIPT-LOCATION as well]
chown OWNER:GROUP FILE/DIRECTORY Changes Ownership of FILES/DIRECTORIES
history
!HISTORY-LINE-NUMBER
Shows the history of all the commands that you have used during your Terminal-Session [Each command has a HISTORY-LINE-NUMBER attached to it]
Re-Runs the command that belonged to/associated with that particular HISTORY-LINE-NUMBER [e.g: !47]
echo TEXT
echo $VARIABLE
Displays/Calls the text specified [e.g: "echo hello"]
Displays/Calls the values contained within that specified VARIABLE [e.g: "echo $SHELL"]
df -h Displays the remaining space in your storage
lsblk Lists out all the storage units & their partitions [The storage drives are denoted by LETTERS & partitions are denoted by NUMBERS]
htop
kill PID
Display all the processes your system is running [The processes have "PROCESS-IDs" attached/associated to them]
Kills/Stops the Process that are associated with that PID [PID means "Process-ID"]
whereis FILE-NAME
which PROGRAMME-NAME
whatis PROGRAMME-NAME
Shows the location of the specified FILE-NAME
Shows the location of binary/executable of that specified PROGRAMME-NAME
Shows the purpose of that specified PROGRAMME-NAME
sudo halt
sudo reboot
Shuts down computer
Reboots the computer
wget
curl
Downloads stuff from a website
Transfers data to & from a server [AKA Downloads & Uploads stuff]
tar -czvf FILE/FOLDER-NAME.tar.gz FILE/FOLDER-NAME
tar -cjvf FILE/FOLDER-NAME.tar.bz2 FILE/FOLDER-NAME
tar -cJvf FILE/FOLDER-NAME.tar.xz FILE/FOLDER-NAME
Compresses files & folders using the "GZip-Compression" algorithm
Compresses files & folders using the "BZip2-Compression" algorithm
Compresses files & folders using the "XZip-Compression" algorithm
tar -xzvf FILE/FOLDER-NAME.tar.gz
tar -xjvf FILE/FOLDER-NAME.tar.gz

tar -xJvf FILE/FOLDER-NAME.tar.gz
Extracts files & folders that were compressed by the "GZip-Compression" algorithm
Extracts files & folders that were compressed by the "BZip2-Compression" algorithm
Extracts files & folders that were compressed by the "XZip-Compression" algorithm
lsb_release -a
cat /etc/*-release
Displays certain LSB [LSB = Linux Standard Base] & distribution-specific information
Finds out what version of Linux-Distro you are running

These are the commands I personally ended up using a lot. But if you want to know more then there's always the documentation. You can visit "https://kernel.org.manpages" to view info about the CLI-Commands & their sections are:-
  1. User-Commands
  2. System-Calls
  3. Library-Functions
  4. Devices
  5. Files
  6. SuperUser & System-Administration Commands
  7. Overview, Connections & Miscellaneous
OR You can visit "https://linux.die.net" to view info about the CLI-Commands as well.