List all links in current directory:
ls -lrt | grep "^l"
Create read only file
chmod 400 file
Find which operating system your system is running on in UNIX
How to run a process in background?
Use “&” in the end of command
To bring to foreground use
To get JOBID use
To kill use
kill -9 PID
To kill all processes in your system except the login shell
Count number of lines in the file
wc -l file
Count number of characters in the file
wc -c file
How do you find which processes are using a particular file?
How to select column 3 and 6 in a CSV file with “,” as a delimiter
cut -f 3,6 -d "," file
How to count a number of non-empty lines in the file?
grep -cve '^\s*$'
In a file word UNIX is appearing many times? How will you count number?
grep -c “Unix” file
How do you find which process is taking how much CPU?
How do you check how much space left in current drive ?
How do you find how many cpu are in your system and there details?
There is a file Unix_Test.txt which contains words Unix, how will you replace all Unix to UNIX?
sed s/Unix/UNIX/g file
Remove all blank lines in the file:
sed '/^$/d' people.csv
Remove all comments (assuming they start with #):
sed '/^#/d' people.csv
Split datafile.csv into files with 1000 lines each, called
datafile.part.00, datafile.part.01 etc…
split -d -l 1000 datafile.csv datafile.part.
How to list all cpp files modified less than 1 day ago
find . -name "*.cpp" -mtime -1
How to delete temporary files using find command in Unix?
find . -name "*.tmp" -print | xargs rm –f
How to find all text file which contains word Exception using find command in Unix ?
find . –name "*.txt" –print | xargs grep "Exception"
How will you find which directory is taking how much space?
du –sh . | grep G
How to synchronize directories with
rsync avz -e 'ssh -i privatekeyfile' /path/to/local/folder/ user2@server1:/path/to/local/folder
A good article on the use of
rsync is here.
How to check software versions?
dpkg -l ipython