Key Linux (Bash) Commands Table

CommandDescription
whoamioutputs the username
hostnameoutputs the computer name
ls -l outputs the long list of directory
man lsShow manual
cat /etc/issueoutputs the distribution and version (ubuntu)
pwdprint working directory
cd /To navigate into the root directory
cd or cd~To navigate to your home directory
cd –Navigate to previous directory
rm -r directorynameRemove directory (non-empty)
clearclear the screen
./HelloAppRun app
stat file_namedetails of the file
cp source destinationCopy file
cp –R * /appCopy recursive all childs to /app destination
find –name vcpufind files
vi …. :q!vi editor and quit command
df –hDisplay file system, disk space usage
(-h means human readable)
type vi
type mkdir
type cd
Tells us where is command binary is or if it is shell built-in.
(shell built-in: code for command included in shell, typically are faster and efficient).
echo $PATHShows path environment variable.
cat ~/.bash_historyoutputs bash commands history
historyoutput current command history
env
env | grep HIST
outputs environment variables.
env | sort | moreoutput list of env variables alphabetically sorted and one page a time
ls -l /etc | morepiping ls to a pager (more/less)
du , du –shDisk usage of directory
–s = summary, h = human readable
free , free -mAmount of free and used memory
–m = MegaBytes
pslist running processes only which are owned by you and associated with current shell
topTable of processes running – to exit press q
uname –aPrints all system information
cat /etc/lsb -releasePrints system information (ubuntu version)
cat /proc/cpuinfoGet CPU Info Using cat Command
Ip addr
Ip a
Ifconfiginterface configurations, let you make changes to network interfaces
eth0 = wired ethernet port
wlan0 = wireless adapter
MacAdress = it is listed next to the label “ether”
nano abc.txtopen file in nano editor
sudo nano abc.txtsusbstitute user do => performs actions as a different user
and if u do not specify any user the default is root user,
which is admin
sudo rebootTo reboot the Linux system from a terminal session
sudo cat /sys/class/dmi/id/board_serialoutput board serial number
jobsoutput list of current shell jobs
(each bash command is a job. Behind the scenes, shell fork itself, create a new process and execute the program code e.g. ls binary onto the new process stack ). Typically these shell commands are foreground jobs.
ping 8.8.8.8 -c 5 > /tmp/pingfile &The & sign in the end makes this command a background job. The command itself redirects the ping (google) 5 times output to a file.
kill [PID]terminate background job. PID is the id given by system when run the background job.
cat /etc/passwd
cat /etc/passwd | grep jawad
output login-shell info
ttyshows which virtual console we are on.
whotells us who else is logged-in
sudo addgroup hadoop
sudo adduser –ingroup hadoop hadoop
Create a hadoop user and group hadoop.
sudo su- hadoopSwitch user to the newly created hadoop user.
tar -xzvf hadoop-3.3.0
sudo mv hadoop-3.3.0 /usr/local/hadoop
extract it, and move it to the appropriate usr/local folder
sudo chown -R hadoop:hadoop usr/local/hadoopGrant ownership of the folder to the hadoop user you created.
apt get install wgetinstall wget package
wget https://wordpress.org/latest.tar.gzdownload wordpress website
tar xzf latest.tar.gzx: extract, z= unzip, f=filename immediately follows
tar czf newabcarch.tar.gz abc/compress& zip abc folder (make tar file)
cut -d: -f3 /etc/group | sort -ntext extraction: -d: (delimiter = colon : ), -f3 (field no. 3)