Linux

#fridayatfidisys

Kalaiselvan
2 min readJul 17, 2020

--

Bash Shell Commands

kalai@Dell:~$

Here ~ denotes you are in home directory and $ represents you are a standard user meaning your permissions to perform operations in the system are limited. If you need to full control then you have to switch to root user.

To check which shell we are in:

echo $SHELL

To list folders/files in the current directory:

ls

To see list of files of other directory:

ls /Documents
ls /Downloads

To list all files in the current directory (even hidden files):

ls -a

To list all files in the current directory (even hidden files) with their permission:

ls -al

Go to home directory — use tilde(~):

~

To print present working directory:

pwd

To go back one level from the current directory to previous directory:

cd ..

To return back to home directory:

cd

or

cd ~

To jump to a particular directory and return back:

pushd /Documentspopd

To find the extension of hidden file:

file .<filename>

To search for a file:

locate <filename>

To find whether some package is installed:

which <package name>Example: which cal 

To see the history of commands which you have used so far:

history

To know what particular command does:

whatis <package name>
whatis cal
whatis brew

To create directory:

mkdir <directory 1> <directory 2>

To create file:

touch <filename>

To copy file:

cp <source file> <target file>

To move file content to another file:

mv <source file> <target file >

To remove file:

rm <filename>

To remove all files inside the directory:

rm -r <directory>

To remove the directory:

rmdir <directory>

To remove all sub-directories inside a directory:

rmdir *

To see content in the file:

cat <filename>

To write content to the file:

cat >> <filename>

To open file with editor:

nano <filename>

To switch to root user temporarily and safely:

sudo -s

To check who logged into the system:

users

To get info about the current user account:

id

To give file execute permission:

chmod +x <filename>

Cheers 😃 😃

--

--

Kalaiselvan

Mobile application engineer| Android tutor| Aviation Enthusiasts