Unix commands Session
~Ranjith
In the layout team, we are learning UNIX command with the support of Sanjeev to improved our skills for automating tasks.
Session on process, kill, disk utility, alias, pushd, popd, tar, and gzip commands:
Process command:
To find process which are all running use “ps” command
ps -ef ; print each (all) process
ps -u <userName>; print process by user
ps -g <groupName>; print process process bu group
groups <username> ; to find group in which user is.
Kill Command:
Used to kill process
kill <signal> <pid> ; send a signal to process <pid>.
kill -l ; signal list;
kill -9 <pid>; -9 is a kill signal
kill -9 -1 ; all process it can.
xkill ; Select the window whose client you wish to kill with button 1….
Disk utility commands:
du -b <path> ; print file space in bytes
du -m <path> ; print file space in megabytes
du -k <path> ; print file space in kilobytes
du -h <path> ; print file space in human readable form.
du -d <depth> -h ; print all files space in given <path> with a given depth.
df -h ; print mounted disk space detail in human readable form
- To find biggest file:
- du -b | sort -nr ; sort file based size (bytes), In sort è n = combine digits into number, r = reverse order
- To find smallest file:
- du -b | sort -n ; sort file based size (bytes), In sort è n = combine digits into number
Send process into background and bring it foreground:
Press Ctrl+z to suspend process.
Type bg to send process into background
Type “jobs” to get job ID.
Type “fg %<job ID>” to bring process into foreground
Alias: set a alternate name to a command or a group of command within quotes separated “;”
alias ls ls -la –color=auto ; set “ls” as a “ls -la –color=auto”.
alias DoYouWantContinue ‘echo “\nDo you want to continue (Y/N):” ; set input = $< ; if($input != “Y” && $input != “y”) exit’ è set DoYouWantContinue as a set of command separated by “;”.
Unalias <alias Name> ; to remove alias;
/<command> ; to run raw command; even when command name is aliased to something else.
Change directory :
cd <path> ; change directory to given path.
cd – ; last cd path.
pushd <path> ; push directory into stack and cd to it.
pushd +<rotate stack number> ; rotate the stack
popd ; pop the top directory in stack
Create Archieve:
tar -cf <archive.tar> <directory> ; Create archive.tar from <directory>, it is like git version control.
tar -tvf <archive.tar> ; List all files in archive.tar verbosely.
tar -xf <archive.tar> ; Extract all files from archive.tar.
tar -d -f <archieve.tar> <directory>; show the difference between tar and files in directory.
tar -u -f <archieve.tar> <directory>; create a new entry for all files with new time stamp(if file is modified).
tar -r -f <archieve.tar> <directory>; append a new file in tar file.
tar -xvf auto.tar test.tcsh –occurrence=2 ; extract 2nd occurrence of test.tcsh file in auto.tar tree.
Compress:
gzip -c <file> ; compress file
gzip -d <file> ; decompress file
gunzip <file> ; unzip file
Author
prathap7618@gmail.com
Related Posts
How to Install WSL and Ubuntu (LTS) on the Windows platform
~Sandhiya.B and Ajay This post consolidates the information needed to set up the Ubuntu terminal on a Win 11 Machine. The Ubuntu terminal...
Read out allAmbient light sensor using a photoresistor and Arduino Uno
This project is about using a photoresistor along with an Arduino Uno board to determine the brightness of a room which is...
Read out allSmart dustbin using Arduino
The smart dustbin is built on a microcontroller-based platform Arduino Uno board which is interfaced with the Servo motor and ultrasonic sensor....
Read out allLOGIC GATES USING ARDUINO UNO
A basic gate is defined as a component with one or more inputs and one output. The inputs and outputs are all...
Read out allLAST SCHOOL STUDENTS VISIT STEMLAND
On the 14th of July students from the Last school, Auroville visited STEMLAND. The forty students accompanied by the teachers enjoyed their...
Read out allVim Editor Session
Vim Editor Session ~SriBhavani and Bakyalakshmi On 18th Jan 2022, we had a session on vim by HarshaVaradhan from AuraSemiconductors. In this...
Read out all