Common Linux terminal commands
This notebook lists common commands used on the Linux terminal.
Right-click
Jupyter’s terminals work with Shift + Right-click. This is
important when you want to paste something copied earlier.
For sftp
If you are inside of
sftp>prompt, the usual commands are executed on the remote machine and the ones in parentheses are executed on local machine.The commands which are not succeeded by parentheses cannot be executed locally (with
las a prefix) fromsftp>prompt.To run any command from inside of the
sftp>prompt, precede it with a!. You can do it for the ones that work withlas a prefix too.
Try out the commands on the following terminal:
from IPython.display import IFrame
your_gitlab_username = "mdrpanwar" # change this to your username
IFrame(
"https://hub.besos.uvic.ca/user/" + your_gitlab_username + "/terminals/3",
width=1200,
height=250,
)
pwd (or lpwd)
Usage:
pwdUsed to get the current working directory(CWD). We will use the term CWD time and again. It means the directory your terminal is in right now. All commands are executed inside this directory.
ls (or lls)
Usage:
ls‘lists’ out the directories and files in the CWD [Hidden directories/files are not shown.]
Use
ls -ato list out even the hidden directories/files.
mkdir (or lmkdir)
Usage:
mkdir dir_nameTo make a directory named
dir_namein the CWD.
cd (or lcd)
Usage:
cd dir_name‘Changes CWD’ to the directory named
dir_name. Heredir_namemust be a directory residing inside the current working directory or a path starting within CWD.Every directory in linux contains
.and.., which refers to thecurrent working directoryandparent of current working directoryrespectively.Use
cd ..to navigate to the parent of the CWD.Consider the following directory structure:
parent
inparent
inchild
simple.out
a.out
b.out
inchild1
incurrentdir
c.out
inparent2
Examples (from inside of
parent/inparent/inchild1):cd ../inparent/inchildcd incurrentdir
rm
Usage:
rm filename_1 filename_2 ... filename_nTo delete the files named
filename_1,filename_2, ….,filename_nfrom the CWD.To delete a directory, use
rm -r dir_namewheredir_nameis a directory residing in CWD or a path to a diretory.Instead of being name of files in CWD,
filename_ican also be a path to a file.Examples (from inside of
parent/inparent/inchild):rm simple.outrm a.out b.outrm ../inchild1/c.out
mv
Usage:
mv filename_1 filename_2 ... filename_n dir_nameTo move
filename_1,filename_2, ….,filename_nto directorydir_name.Instead of being name of file in CWD,
filename_ican also be a path to a file.Instead of being name of directory in CWD,
dir_namecan also be a path to a directory.Examples (from inside of
parent/inparent/inchild1):mv c.out incurrentdirmv ../inchild/a.out ../../inparent2
cp
Usage:
cp filename_1 filename_2 ... filename_n dir_nameTo copy
filename_1,filename_2, ….,filename_ntodir_namedirectory.To copy a directory
dir_name1into directorydir_name2, usecp -r dir_name1 dir_name2wheredir_name1anddir_name2are directories residing in CWD or paths to directories..Instead of being name of file in CWD,
filename_ican also be a path to a file.Instead of being name of directory in CWD,
dir_namecan also be a path to a directory.Examples (from inside of
parent/inparent/inchild1):cp c.out incurrentdircp ../inchild/a.out ../../inparent2
top
Usage:
topLists out all the running processes with the resourses being used by each process.
The output is similar to that of
Task Manageron Windows.