System Commands PDF
System Commands PDF
A hypervisor is a software that creates and runs virtual machines. It can run multiple
operating systems simultaneously by sharing the resources of the host machine.
cd .. - parent directory
cd - - previous directory
cd ~ - home directory ( same as cd )
date -R - date and time in rfc 5322 standard ( used in email communications)
man date - manual/ help page of date command
press q - to exit the help page
cal - to get the calendar
ncal - calendar in different orientation
free - memory available
free -h - memory available in human readable format
groups - groups that current user belongs to
mkdir - to make a directory
To give or remove permissions(read, write or execute) for group, user or others:-
chmod (u or g or o)(+ or - )(r or w or x ) folder name
OR
chmod 700 folder name [here 700 represents rwx- - - - - -]
touch file1 - touch command is used to change the timestamp of last
modified information about that particular file or folder. If the file doesn’t exist then it
creates an EMPTY file.
cp file1 file2 - to make a copy of file1 with a name file2
mv file2 .. - to move file2 to its parent directory (.. represents parent
directory)
Hard links = no. of files having same inode number OR no. of different entries in the
filesystem
“-” files have only one hard link
WEEK 2
Multiple use of / is the same as using it one time.
/ is called root directory. Root directory is its own parent.
/proc and /sys are stored in memory, not on hard disk. These are two file systems
which help us to know more about the hardware.
/proc - processes running are stored in this directory
df -h - partition sizes and other information in human readable
format
$hell Variables:
makes it possible to communicate between 2 processes very efficiently without
needing to read and write the file system. Also, used to store the information as an
intermediate form to process further.
echo - to print string or values of variables on to the screen (
removes the extra spaces from the string, To actually print the spaces put the string in
quotes)
Every shell variable will start with a $
`` (back quotes) and $() are used to redirect the output of a command to a variable.
eg var1=`ls -l` or var1=$(ls -l)
Process control:
-Use the & at the end of command to run the process in the background
fg - to bring the process to the foreground
coproc - to run a command and use shell altogether(coprocess)
jobs - list all the programs running in the background
top - to look at the processes hogging the memory
kill - we could kill some processes owned by us
The above two tests have different meanings of 0 and 1 output. Read carefully.
List of variable names:-
! asks for name of variable and # asks for length of the value of variable
Length of the string value:-
offset can be negative(right to left in string) as well (but there should be one space
after colon for negative sign)
(eg. 5 means skip 5 characters from front, -5 means take the last 5 characters and use
those only)
REMOVE matching pattern:-
This prints the pattern that is not matching the given pattern.
WEEK 3
ls $HOME /blah > file1 2> file1 error msg goes to file1 and then overwritten
by $HOME output
ls $HOME /blah > file1 2>&1 both error and the output will be present in
the file (initial content of the file will be overwritten) (no space between 2>&1)
SOFTWARE MANAGEMENT
Need for a package manager
● Tools for installing, updating, removing, managing software
● Install new/updated software across network
● Package - file look up, both ways
● Database of packages on the system including versions
● Dependency checking
● Signature verification tools
● Tools for building packages
To get checksum strings:
● md5sum file1.txt
● sha1sum file1.txt
● sha256sum file1.txt
hwinfo
lshw -list hardware
cat /proc/cpuinfo - display processors that are available
or cpu details
cat /proc/partitions -partitions info
lsblk -o NAME,SIZE - list the block devices
lspci - list pci devices
free - display free memory, swap memory
hardinfo -gui details
clinfo - tells about libraries supported by graphic card
upower -e - to know about battery devices and their status
iostat
PS1=“set new prompt format”
source .bashrc - to get back the default prompt
sed -n -e ‘=; 5,8p’ filename -to print line number of all lines and print
lines from 5 to 8
sed -n -e ‘5,8{=;p}’ filename -to print line number and lines from 5 to 8
sed -n -e ‘1~3p’ filename - print 1st line and then print every 3rd line
from first
sed -e ‘5d’ filename -to delete 5th line and print the rest (line is
not actually deleted from the file”
WEEK 7
field separator can be Regex as well in awk
WEEK 8
Version Control
save- a new version of code
make- compile only those parts of code that have changed
“Each programmer has multiple versions of each file they worked on!”
Version Control - trace back to working version of code
versions - #users * #files * #version - requires database to hold