Basic unix commands Flashcards

to crack the interviews

1
Q

create a tar archive file tecmint-14-09-12.tar for a directory /home/tecmint in current working directory

A

tar -cvf tecmint-14-09-12.tar /home/tecmint

-cvf options specified? no? then rate 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

create a compressed MyImages-14-09-12.tar.gz file for the directory /home/MyImages

A

tar -cvzf MyImages-14-09-12.tar.gz /home/MyImages

right extension of tar file, no-rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

create a Phpfiles-org.tar.bz2 file for a directory /home/php

A

tar -cvfj Phpfiles-org.tar.bz2 /home/php

options specified? no? then rate 2
right extension of tar file, no-rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

untar the file public_html-14-09-12.tar in present working directory

A

tar -xvf public_html-14-09-12.tar

options specified? no? then rate 2
if said untar instead of tar -x, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Uncompress tar.gz archive file in different working directory /etc/psswd -the absolute path

A

tar -xvf public_html-14-09-12.tar.gz -C /etc/psswd

options specified? no? then rate 2
if said untar instead of tar -x, rate 1
right extension of tar file, no-rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Uncompress highly compressed tar.bz2 file

A

tar -xvf public_html-14-09-12.tar.bz2

options specified? no? then rate 2
if said untar instead of tar -x, rate 1
right extension of tar file, no-rate 3
no j in the options during uncompress-note this

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

list the content of uploadprogress.tar file.

A

tar -tvf uploadprogress.tar

options specified? no? then rate 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

list the content of tar.gz file

A

tar -tvf uploadprogress.tar.gz

options specified? no? then rate 2
right extension of tar file, no-rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

list the content of tar.bz2 file

A

tar -tvf uploadprogress.tar.bz2

options specified? no? then rate 2
right extension of tar file, no-rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

extract a single file called cleanfiles.sh from cleanfiles.sh.tar

A

tar -xvf cleanfiles.sh.tar cleanfiles.sh

command arguments in same order or not? no -rate 3
options specified? no? then rate 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

extract a single file tecmintbackup.xml from tecmintbackup.tar.gz archive file

A

tar -zxvf tecmintbackup.tar.gz tecmintbackup.xml

command arguments(not options) in same order or not? no -rate 3
options specified? no? then rate 2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

extract a single file called index.php from the file Phpfiles-org.tar.bz2

A

tar -jxvf Phpfiles-org.tar.bz2 index.php

command arguments(not options) in same order or not? no -rate 3
options specified? no? then rate 2
j and respective z options are required here

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

extract or untar multiple files from the tar, tar.gz and tar.bz2 archive file

A

tar -jxvf Phpfiles-org.tar.bz2 “file1.xml”,” file2.xml”
tar -zxvf tecmintbackup.tar.gz “file1.xml”,” file2.xml”
tar -xvf cleanfiles.sh.tar “index.php” , “k2.php”

options specified? no? then rate 2
command arguments(not options) in same order or not? no -rate 2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

extract a group of all files whose pattern begins with .php from a tar, tar.gz and tar.bz2 archive file

A

tar -jxvf Phpfiles-org.tar.bz2 –wildcards ‘.php’
tar -zxvf tecmintbackup.tar.gz –wildcards ‘
.php’
tar -xvf cleanfiles.sh.tar –wildcards ‘*.php’

options specified? no? then rate 2
command arguments(not options) in same order or not? no -rate 2
quotations and regex not correct, rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

add file xyz.txt and directory php to existing tecmint-14-09-12.tar archive file

A

tar -rvf tecmint-14-09-12.tar xyz.txt
tar -rvf tecmint-14-09-12.tar php

options specified? no? then rate 2
command arguments(not options) in same order or not? no -rate 2
quotations and regex not correct, rate 3
didnt identify which option for append, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

add files or directories to an existing compressed tar.gz and tar.bz2 archive file

A

tar -rvf tecmint-14-09-12.tar.gz xyz.txt
tar -rvf tecmint-14-09-12.tar.bz2 php

options specified? no? then rate 2
command arguments(not options) in same order or not? no -rate 2
quotations and regex not correct, rate 3
didnt identify which option for append, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

check the size of any tar, tar.gz and tar.bz2 archive file

A

tar -czvf tecmint-14-09-12.tar.gz xyz.txt | wc -c
tar -cjvf tecmint-14-09-12.tar.bz2 php | wc -c

options specified? no? then rate 2
command arguments(not options) in same order or not? no -rate 2
quotations and regex not correct, rate 3
didnt identify which option for size check , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

see the actual content of that tar file

A

tar -tvf actualcontent.tar

options specified? no? then rate 2
right extension of tar file, no-rate 3
didn’t understand the question , rate 1
didn’t remember the right option, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

create tar file in Unix with just specified contents

A

tar -cvf equitytrading.tar equity currency

command arguments(not options) in same order or not? no -rate 2
didn't understand the question , rate 1
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

view contents of gzip tar file

A

tar -ztvf trading.tgz

options specified? no? then rate 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

know the size of tar file before creating it

A

tar -cf - * | wc -c

didn’t understand the question , rate 1
options specified? no? then rate 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How To Uncompress A Tar.Gz In Another Directory

A

tar xzf archive.tar.gz -C /destination

didn’t understand the question , rate 1
options specified? no? then rate 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Using tar -xzvf filename.tar.gz doesn’t extract the file. it is gives this error:

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error exit delayed from previous errors

A

If file filename.tar.gz gives this message: POSIX tar archive, the archive is a tar, not a GZip archive.

Unpack a tar without the z, it is for gzipped (compressed), only:

mv filename.tar.gz filename.tar # optional
tar xvf filename.tar

didn’t understand the question , rate 1
options specified? no? then rate 2
don’t remember the solution, rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How to check if a Unix .tar.gz file is a valid file without uncompressing?

A

What about just getting a listing of the tarball and throw away the output, rather than decompressing the file?

tar -tzf my_tar.tar.gz >/dev/null

This test in no way implies integrity of the data. Because it was designed as a tape archival utility most implementations of tar will allow multiple copies of the same file!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

How do I tar a directory of files and folders without including the directory itself?

A
$ mkdir my_directory
$ touch my_directory/file1
$ touch my_directory/file2
$ touch my_directory/.hiddenfile1
$ touch my_directory/.hiddenfile2
$ cd my_directory/ && tar -zcvf ../my_dir.tgz * && cd ..
./
./file1
./file2
./.hiddenfile1
./.hiddenfile2
$ tar ztf my_dir.tgz
./
./file1
./file2
./.hiddenfile1
./.hiddenfile2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is the difference between tar and zip? What are the use cases for each?

A

tar in itself just bundles files together, while zip applies compression as well.

Usually you use gzip along with tar to compress the resulting tarball, thus achieving similar results as with zip

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

How can you untar more than one file at a time?

A

find -iname *.tar -exec tar -xvf {} \

if can’t think of exec or xargs, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Untar a file in current directory or in a specified directory

A

tar xvfj file.tar
tar xvfj file.tar -C path of file in directoy

didn’t understand the question , rate 1
options specified? no? then rate 2
don’t remember the solution, rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

list only for the mentioned text or image from archived file.

A

tar tvf file.tar | grep “text to find”
tar tvf file.tar | grep “filename.file extension”

don’t remember the command to use, rate 1
didn’t understand the question , rate 1

–wilcards can’t be used?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

views the archived files along with their details like the file name that’s archived in the given tar file

A

tar tvf file.tar filename

don’t remember the argument to use at the end, rate 1
didn’t understand the question , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Viewing the Archive file.tar

A

tar tvf file.tar

don’t remember the argument to use at the end, rate 1
didn’t understand the question , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Creating an uncompressed archive using tar command

A

tar cvf archive_name.tar dirname/

don’t remember the options to use , rate 1
didn’t understand the question , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

make a tar file out of two specific files file1, file2 in a specified directory

A
$ ls
abc  def
$ tar cvf compressed.tar abc def
abc
def
$ ls
abc  compressed.tar  def

if dont know that passing specified filenames is an option to tar only them, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

Listing an uncompressed archive using tar command

A

tar tvf archive_name.tar

didn’t understand the question , rate 1
don’t know listing imples option t, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Listing a compressed archive using tar command

A

tar tvfz archive_name.tar.gz
tar tvfj archive_name.tar.bz2

didn’t understand the question , rate 1
don’t know listing imples option t, rate 1
don’t know what compressed archive imples option t, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

You cannot add file or directory to a compressed archive. If you try to do so, you will get “tar: Cannot update compressed archives” error

A

do u know this very well?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

estimates the tar file size ( in KB ) before you create the tar file

A

tar -cf - /directory/to/archive/ | wc -c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

Find all the files whose name is tecmint.txt in a current working directory

A

find -name techmint.txt /path/to/current/working/dir
shouldn’t be your answer

The right answer is
find . -name techmint.txt

-name option if not specified, rate 1
if doesnt strike that . = current working dir, rate 1
command arguments(not options) in same order or not? no -rate 2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

Find all the files under /home directory with name tecmint.txt

A

find /home -name techmint.txt

if not specified the full file name with extensions, rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

Find all the files whose name is tecmint.txt and contains both capital and small letters in /home directory.

A

find /home -iname techmint.txt

if not specified the full file name with extensions, rate 3
if not specified the i letter before name , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

Find all directories whose name is Tecmint in / directory.

A

find / -name Techmint

The question implies that techmint is the name for multiple directories, if dont understand this -rate 2
if any quotations are added, rate 4 coz its plain-no quotations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

Find all php files whose name is tecmint.php in a current working directory

A

find . -type f -name techmint.php

if missed the type -f option-it could bring in directories with such name too(possible)- rate 2
If don’t watch out that the question only asked for files and not the directories- rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

Find all php files in a directory

A

find /path/to/dir -type f -name “*.php”

If don’t understand that its a wildcard or regex -rate 2
if don’t put it in “”, rate 2
if don’t put along with the -name option, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

Find all the files whose permissions are 777

A

find . -type f -perm 0777 -print

if don’t know that / means check all dirs in current dir, rate 1
if are specific that you want to print to std out like screen, rate 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

Find all the files without permission 777

A

find . -type f ! -perm 0777 -print

if don’t know that ! means a negation before an option, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

Find all the SGID bit files whose permissions set to 644

A

find . -type f -perm 2644

if the first bit is set to 2 , sgid bit is set-dont know this rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

Find all the Sticky Bit set files whose permission are 551

A

find . -type f -perm 1551

if the first bit is set to 1 , sticky bit is set-dont know this rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

Find all SUID set files

A

find . -type f -perm /u=s

if don’t remember that -perm option is used, rate 1
if don’t remember the argument to -perm userid set bit which is /u=s(set suid), rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

Find all SGID set files.

A

find . -type f -perm /g=s

if don’t remember that -perm option is used, rate 1
if don’t remember the argument to -perm userid set bit which is /g=s(set sgid), rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

Find all Read Only files

A

find . -perm /u=r

if don’t remember that -perm option is used, rate 1
if don’t remember the argument to -perm userid set bit which is /u(user)=r(read), rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

Find all Executable files

A

find . -perm /u=x

if don’t remember that -perm option is used, rate 1
if don’t remember the argument to -perm userid set bit which is /a(any user or all )=x(execute), rate 1,
use /u(user)=x rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

Find all 777 permission files and set permissions to 644

A

find . -perm 0777 -exec chmod 0644 {} /;

If don’t remember that -perm option is used, rate 1
if don’t remember that -exec option is used, rate 1
if don’t remember that {} ‘; syntax is at the end of -exec option, rate 1
If don’t remember that -chmod option is used to set permissions, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

Find all 777 permission directories and set permissions to 755

A

find . -type d-perm 0777 -exec chmod 0644 {} /;

if don’t note that the permissions are to be set for directories, rate 1
If don’t remember that -chmod option is used to set permissions, rate 1
If don’t remember that -perm option is used, rate 1
if don’t remember that -exec option is used, rate 1
if don’t remember that {} ‘; syntax is at the end of -exec option, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

find a single file called tecmint.txt and remove it

A

find . -name techmint.txt -exec rm -rf {} /;

If don’t remember that -rm option for deleting or removing, rate 1
If don’t remember that -perm option is used, rate 1
if don’t remember that -exec option is used, rate 1
if don’t remember that {} ‘; syntax is at the end of -exec option, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

find and remove multiple files such as .mp3

A

find . -name “*.txt” -exec rm-rf {} /;

if don’t remember multiple files with a pattern has to be in “ “, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

find all empty files under certain path

A

find . -type f -empty

if don’t remember , -empty is an option , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

find all empty directories under certain path

A

find . -type d -empty

if don’t remember , -empty is an option , rate 1
if don’t notice the question is on directories , and use -type d , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

To find all hidden files

A

find . -type f -name “ .*”

if don’t remember that . is the pattern of the hidden file start-rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

find all or single file called tecmint.txt under / root directory of owner root

A

find / -type f -user root -name techmint,txt

if don’t remember that the option is -user ,rate 1
if the options are in wrong order, rate 3
if dont rememeber / corresponds to root dir, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

find all files that belongs to user Tecmint under /home directory

A

find /home -user Techmint -type f

if added any extra options like -name , rate 1
if the options are in wrong order, rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

find all files that belongs to group Developer under /home directory

A

find /home -group developer -type f

If don’t remember that the option is -group ,rate 1
if added any extra options like -name , rate 1
if the options are in wrong order, rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

find all .txt files of user Tecmint under /home directory

A

find /home -type f -iname “*.txt” -user Techmint

if don’t remember that the option is -user ,rate 1
if the options are in wrong order, rate 3
if dont rememeber / corresponds to root dir, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q

find all the files which are modified 50 days back

A

find . -type f -mtime 50

if don’t remember that the option is -mtime ,rate 1
if have any + or - sign , rate 3,since asked just precise 50 days

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
64
Q

find all the files which are accessed 50 days back

A

find . -type f -atime 50

if don’t remember that the option is -atime ,rate 1
if have any + or - sign , rate 3 ,since asked just precise 50 days

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

nd all the files which are modified more than 50 days back and less than 100 days

A

find . -type f -mtime +50 -mtime -100

If don’t remember that the option is -mtime ,rate 1
If don’t remember that the option is -mtime should be used two times to specify range ,rate 1
f don’t remember that the option is -mtime arguments have +, - signs ,rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
66
Q

find all the files which are changed in last 1 hour

A

find . -type f -cmin 60

if confused with cmin and mmin, rate 3
if don’t remember the cmin option, rate 1
if don’t remember the arguments are in minutes count, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
67
Q

find all the files which are modified in last 1 hour

A

find . -type f -mmin 60

if confused with cmin and mmin, rate 3
if don’t remember the cmin option, rate 1
if don’t remember the arguments are in minutes count, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
68
Q

find all the files which are accessed in last 1 hour

A

find . -type f -amin 60

if confused with cmin and mmin, rate 3
if don’t remember the cmin option, rate 1
if don’t remember the arguments are in minutes count, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
69
Q

find all 50MB files

A

find / -type f -size 50M

if don’t remember the -size option, rate 1
if don’t remember the option’s argument needs to specify the unit of size, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
70
Q

find all the files which are greater than 50MB and less than 100MB

A

find / -type f -size +50M -size +100M

If don’t remember that the option is -size ,rate 1
If don’t remember that the option is -size should be used two times to specify range ,rate 1
f don’t remember that the option is -size arguments have +, - signs ,rate 1
if don’t remember the option’s argument needs to specify the unit of size, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
71
Q

find all 100MB files and delete them using one single command

A

find / -type f -size 100M -exec rm -rf {} /;

if don’t remember the -size and -exec for deleting -rm, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
72
Q

Find all .mp3 files with more than 10MB and delete them using one single command

A

find / -type f -name “*.mp3” -size +10M -exec rm -rf {} /;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
73
Q
Symbol	
1	f	
2	d	
3	b	
4	c	
5	p	
6	l	
7	s
A
Type
Regular file
Directory file
Block file
Character file
Pipe file
Symbolic link file
Socket file.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
74
Q

Search for all the files whose StickyBit is set

A

find / -perm /o=t

if dont know o means others and t is for sticky, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
75
Q

Search for all the files whose owener permissions is read only

A

find / -perm /u=r

if don’t know u means owner and r is for read pnly , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
76
Q

Search for all the files which have user, group and others with executable permissions

A

find / -perm /a=x

if don’t know a means owner, user and all others and x is for execution , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
77
Q

want to get all the files which are created later this file creation newer.txt .

A

find / -newer newertxt

need to know that -newer is an option, rate 1 if no

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
78
Q

Search for files whose size is more than 10bytes

A

find / -type -f -size +10c

if don’t now that c is used for bytes notation of size in units, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
79
Q

Search for files which are exactly 10kb in /opt folder

A

find /opt -type -f -size 10k

if don’t now that k is used for kilo bytes notation of size in units, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
80
Q

find all the empty files in my system

A

find /opt -type -f -size 0k

if don’t now that k is used for kilo bytes notation of size in units for empty files too , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
81
Q

Search for files which are more than 1GB size in /usr folde

A

find /opt -type -f -size +1G

if don’t now that G is used for giga bytes notation of size in units, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
82
Q

Find all the files with SGID for the group sales and with size exactly 100MB with file name as pass.txt under /opt.

A

find /opt -size 100M -group sales -perm g+s -name pass.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
83
Q

Find all the files which are more than 100MB and less than 1GB in size.

A

find / -size +100M -size -1G

if don’t know to put appropriate units near the -size’s argument, rate 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
84
Q

: find a file with passwd.txt in /var folder and long list this file for checking file properties

A

find /var -iname passwd.txt -exec ls -l {} ;

if dont remeber long listing option is for ls , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
85
Q

Find all the files with name test.txt in /mnt and change the ownership of the files from Surendra to Narendra

A

find /mnt -type f -name test.txt -user Surendra -exec chown Narendra {} \;

if don’t remember that exec needs to be used, rate 1
if don’t remember that chown needs to used with exec to do modifications on the found files, rate 2
if added extra options with chown, rate 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
86
Q

finding a file with inode number

A

find /mnt -type f -inode 23

if don’t remember the inode number , then rate 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
87
Q

Find all the files with name test.sh in /abc folder and then grep if for word is there in that file or not

A

find /abc -type f -name test.sh -exec grep “for” {} \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
88
Q

Find all the files with name xyz.txt owned by Surendra in /var/ftp/pub and change the permissions to 775 to them.

A

find /var/ftp/pub -type f -name xyz.txt -user Surendra -exec chmod 775 { } \;

make sure you have included all the filter options, rate 4 if missed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

Find all the files with name temp.txt in /xyz folder and backup then compress them to send it for saving

A

find /xyz -type f -name temp.txt -exec tar -cvfz backup.tar.gz {} /;

any small obvious mistake , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
90
Q

Find files with name abc.txt in /home directory and take backup of each file before modifying it

A

find /xyz -type f -name temp.txt -exec cp {} {}.bkf /;

If doesn’t strike to use cp command, rate 1
if don’t remember that cp follows w=by the current path of the file represented by {} in -exec command , rate 1
If don’t remember the cp syntax, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
91
Q

Find all the files with executable permissions and display their checksum value

A

find /con -type f -perm /a=x -exec -md5sum {} \;

if don’‘t remember that md5sum is the command for the checksum, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
92
Q

Find all the files with name abc.txt and owner as surendra then move them to /opt folder

A

find /com -type f -name abc.txt -user surendra -exec mv {] /opt/ \;

If doesn’t strike to use mv command, rate 1
if don’t remember that mv follows by {}. rate 1
the current path of the file represented by {} in -exec command , rate 1
If don’t remember the mv syntax, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
93
Q

Find files with abc.txt name in /opt directory change the owner permissions from Surendra to Narendra and change the permissions to 775

A

find /com -type f -name abc.txt -user surendra -exec chown Narendra \; -exec chmod 775 \;

If you don’t remember that We can use this multiple -exec option more than two times, rate 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
94
Q

Find abc.txt file in /opt and /var folder at a time

A

find /opt /var -name abc.txt

If you don’t remember that two locations can be specified side by side, rate 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
95
Q

Search multiple locations but not in particular location. Find abc.txt file in /opt and /var folder at a time, Search in entire system expect /proc folder

A

find /opt /var -path /proc -prune -name abc.txt

if don’t remember this - The -path variable to define the path of a location. And -prune combined with -path will say not to descend in to the mention path /proc- rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
96
Q

search for abc.txt and hash.c file at a time

A

find /opt /var -name abc.txt -o -name hash.c

if don’t know that the -o should be followed by the specific previous option , rate 3
if don’t know h=that -o option should be used to find for something together, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
97
Q

find two directories say opt and var how can i find them

A

find . -type d -name opt -o -type d-name var

if don’t understand the question, rate 1
if doesn’t strike that its type d option, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
98
Q

Finding files only in the current directory not searching on subdirectories

A

find . -maxdepth 1 -type f -newer first_file

if don’t remember the maxdepth option, rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
99
Q

find all of the symbolic links in your home directory, and print the files your symbolic links points to

A

find . -type l -print0 | xargs -o ls -ld | awk ‘{print $10}’

10th field has the actual link pointing, remember if forgot, rate 3
if forgot about the awk syntax, rate 2
if forgot about symbolic links , rate 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
100
Q

always use find -print0 along with xargs -0 if you see slightest possibilities of file names containing space in UNIX or Linux

A

know this or not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
101
Q

/bin for what

A

executable files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
102
Q

/ for what

A

root dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
103
Q

/etc

A

config files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
104
Q

/tmp for

A

only temporary files, they clear during boot time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
105
Q

/opt for

A

installing software not bundled with os

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
106
Q

/var for

A

log files created by programs and applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
107
Q

/cdrom for

A

mount point for files on cdrom

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
108
Q

/media for

A

mount point for cdrom and dvd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
109
Q

/srv for

A

web files, ftp server files /srv/ftp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
110
Q

/opt/avg/bin

A

executable files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
111
Q

/etc/opt/myapp

A

configuration files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
112
Q

/var/opt/myapp

A

log files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
113
Q

long listing of files and dir

A

ls -l

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
114
Q

long listing of hidden files

A

ls -la

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
115
Q

listing of only files not directories

A

ls -F

@ link
/ dir
* binary executables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
116
Q

how to execute a binary execuatable file

A

./binaryfilename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
117
Q

listing of files with time

A

ls -t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
118
Q

listing of files recursively

A

ls -R

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
119
Q

listing of directories only

A

ls -d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
120
Q

ls -R alternative is

A

tree

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
121
Q

listing of files in revers order, can this command be confused with anything elsr

A

ls -r

yes with ls -R which is a recursive listing not reverse listing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
122
Q

directory structure

A

tree -d

tree - c to colorize output

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
123
Q

listing with colorized output

A

ls –color

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
124
Q

edit a file using editor

A

vi filename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
125
Q

modes of vi

A

3

command, insert, line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
126
Q

get into vi command mode by

A

ESC key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
127
Q

get into vi insert mode by

A

i - to insert right at after the cursor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
128
Q

in vi insert mode, to append right after cursor is

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
129
Q

in vi insert mode, to append at the beginning of the line is

A

a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
130
Q

in vi insert mode, to insert at the beginning of the line is

A

I

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
131
Q

what are the navigation commands in command mode

A

h left j down k up l right

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
132
Q

how to get into line mode in vi

A

type : followed by the command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
133
Q

to save writes in line mode

A

:w

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
134
Q

to force save writes in line mode

A

:w!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
135
Q

to quit in line mode

A

:q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
136
Q

to force quit in line mode

A

:q!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
137
Q

to save writes and force quit, its alternative also in line mode

A

:wq! :x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
138
Q

navigating through lines in line mode, to position cursor at line n

A

:n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
139
Q

navigating through lines in line mode, to position cursor at the line end

A

:$

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
140
Q

navigating through lines in line mode, to turn on line numbers

A

:set nu

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
141
Q

navigating through lines in line mode, to turn off line numbers

A

:set nonu

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
142
Q

navigating the command mode, to delete a character

A

x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
143
Q

navigating the command mode, to delete a word

A

dw

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
144
Q

navigating the command mode, to delete a line

A

dd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
145
Q

navigating the command mode, to delete from current position

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
146
Q

navigating the command mode, to change current character

A

r

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
147
Q

navigating the command mode, to change current word

A

cw

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
148
Q

navigating the command mode, to change current line

A

cc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
149
Q

navigating the command mode, to change from current position

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
150
Q

navigating the command mode, to change case of a charecter

A

~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
151
Q

copy a word in command mode vi

A

yy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
152
Q

in command mode vi , copy 3 words

A

y3w; y

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
153
Q

in command mode vi, paste the copied or deleted word

A

p

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
154
Q

in command mode vi, undo

A

u

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
155
Q

in command mode vi, redo

A

Cntrl+ R

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
156
Q

to search in vi, line mode- forward searching

A

/pattern ( n for next, N for previous match)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
157
Q

to search in vi, line mode- backward searching

A

? n for next, N for previous match

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
158
Q

Display current running processes

A

ps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
159
Q

Display current running processes not owned and running as you

A

ps -e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
160
Q

Display the full format of the process

A

ps -f

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
161
Q

Display process running on root

A

ps -u root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
162
Q

Display process details of process 123

A

ps -p 123

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
163
Q

Display process tree

A

ps -e –forest

pstree

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
164
Q

Interactive process view

A

top

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
165
Q

What are environment variables for

A

they specify storage location and has a name and a value, they affect the way programs behave

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
166
Q

the command to know all the environment variables

A

printenv

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
167
Q

List few names of environment variables

A

TZ,HOME,PATH

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
168
Q

another way than printenv to print the contents of environment variables are

A

echo $ENVIRONMENT VARIABLE NAME($HOME)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
169
Q

Create an environment variable name VAR with a value -value

A

export VAR=’value’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
170
Q

Update an environment variable EDITOR to vi

and TZ environemnt variable to ‘US/Pacific’

A

export EDITOR=”vi”

export TZ=”US/Pacific”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
171
Q

Remove environment variable TZ to revert it’s value to default

A

unset TZ

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
172
Q

Does an unset and export command persist changes between logins?

A

No,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
173
Q

How to persist changes in environment variables between logins

A

vi .bash_profile

insert mode, go to the end
export TZ="US?Pacific"
\:wq!
exit
login to shell
printenv TZ or echo $TZ
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
174
Q

what is the pager utility to print output upto the screen fit

A

pipe the output to less command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
175
Q

How to tell if a particular program or an application is using a particular environment variables

A

man commandname will display the man pages with a section on environment variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
176
Q

command for background process

A

&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
177
Q

what to do to kill a foreground process like:

sleep 300

A

Cntrl + C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
178
Q

what to do to suspend a foreground process like:

sleep 300

A

Cntrl + Z

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
179
Q

How to foreground a background process

A

fg %jobid ;fg %3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
180
Q

How to background a running foreground process

A

bg %jobid; bg (will background the latest process evoked)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
181
Q

How to kill a job

A
kill %jobid; kill %3
kill pid; kill 103458
kill -TERM pid; kill -TERM 123
kill 15 123
kill -9 123 (9 kill signal)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
182
Q

what is kill’s kill signal

A

9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
183
Q

what is kill’s termination signal

A

15

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
184
Q

what is signal 15’s in kill, it’s also used interchangebaly

A

-TERM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
185
Q

command to list all the jobs

A

jobs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
186
Q

command to list job details of a job with id 1

A

jobs %1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
187
Q

command to list the current job(recent /latest job id)

A

job %+

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
188
Q

command to list the previous job id

A

job %-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
189
Q

what in unix helps to do time based job scheduling

A

cron services

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
190
Q

Tell more about cron services

A

cron job starts when the system boots,
it performs routine maintenance
and it automates a process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
191
Q

syntax of thecrontab command

A
min hr dom month dow  /path/to/the/executable/file
min(0-59)
hr(0-23)
(dom= day of the month) (1-31)
(dow=day of the week)(0-6)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
192
Q

schedule a cron job located at /opt/sales/bin/weekly-report every monday at 7 pm

A

min hr dom month dow

0 19 * * 1 /opt/sales/bin/weekly-report

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
193
Q

perform a half hourly check

A
0,30 * * * * /opt/sales/bin/weekly-report
*/2 * *  * * /opt/sales/bin/weekly-report
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
194
Q

perform a check every first 5 min of the hr

A

0-5 * * * * /opt/sales/bin/weekly-report

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
195
Q

Perform a cron job annually

A

0 0 1 1 * /opt/sales/bin/weekly-report

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
196
Q

Perform a cron job weekly

A

0 0 * * 0 path/to/the/executable/file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
197
Q

Perform a cron job monthly

A

0 0 1 * * path/to/the/executable/file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
198
Q

Perform a cron job daily

A

0 0 * * * path/to/the/executable/file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
199
Q

Perform a cron job hourly

A

0 * * * * path/to/the/executable/file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
200
Q

What command manipulates cron jobs

A

chrontab command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
201
Q

command to install a cron job from file

A

crontab file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
202
Q

command to list cron jobs

A

crontab -l

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
203
Q

command to edit cron job files

A

crontab -e (should open ur favrt editor: set an environment variable)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
204
Q

command to remove all your cron jobs

A

crontab -r

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
205
Q

how to create a cron job

A

1) open a vi editor with the file name => vi my-cron
2) in insert mode type 07 **1 /opt/sales/bin/weekly-report
3) :wq!
4) install the file with crontab command => crontab my-cron
5) echo $ EDITOR
6) export EDITOR =vi
7) crontab -e to do any edits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
206
Q

command as a way to start a session as another user is

A

su

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
207
Q

how to start a session as root user

A

su with no arguments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
208
Q

execute a command by starting a session as a root user

A

su -C command; su -C ls -l

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
209
Q

command to know the what is the current user in our session

A

whoami

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
210
Q

how to stay with the same environment while switched as a user

A

su oracle ( with out - before the user name )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
211
Q

how to change to the user’s environment while switched as a user

A

su - oracle (with the - and space followed by a username)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
212
Q

command to switch user to obtain privileges and security of super user

A

sudo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
213
Q

Does sudo prompts for a password?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
214
Q

list of available commands as superuser switching

A

sudo -l

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
215
Q

to execute a command as privileged user sqoop

A

sudo -u sqoop command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
216
Q

to execute a command as privileged user sqoop and also switch to the users environment

A

sudo su - sqoop command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
217
Q

command to start a shell as root

A

sudo -s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
218
Q

command to start a shell as sqoop

A

sudo -u sqoop -s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
219
Q

command to modify sudo configurations

A

sudo visudo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
220
Q

command to copy files from one local machine to linux server

A

scp source destination

scp z.txt linuxserver(hostname):~ (~ shortcu for hoe dir)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
221
Q

command to copy files from one local machine to linux server interactively

A

sftp linuxserver

pwd
ls

lpwd # local path to directory

lls # local list files

put z.txt

ls
rm z.txt

quit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
222
Q

Transfer this z.txt file as different user: adminuser

A

scp z.txt adminuser@linuxserver:/home/adminstration

or

sftp adminuser@linuxserver

pwd
ls

lpwd # local path to directory

lls # local list files

put z.txt

ls
rm z.txt

quit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
223
Q

command to find difference between contents of file 1 AND file 2

A

diff file1 file2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
224
Q

explain the output of diff file1 file2 command : 3c3

A

file1lineno change - c file2lineno

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
225
Q

if the difference between two files is addition of txt at the 8th line then o.p of diff file1 file2 would be

A

4a4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
226
Q

if the difference between two files is addition of txt at the 8th line then o.p of diff file1 file2 would be 4a4, Now to see what line was added and the diff the command woud be

A

sdiff file1 file2

or vimdiff file1 file2 (to view ffiles in two diffent windows)

symbol for differing lines
> lines exist only in 2nd file
< lines exist only in 1rst file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
227
Q

To quit seeig both the file windows using vimdiff command then

A

:qa!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
228
Q

To quit seeing both the file windows using vimdiff command then

A

:q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
229
Q

Command to remove file

A

rm file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
230
Q

command to reove directory

A

rm -r -dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
231
Q

command to copy a lift of files to /home

A

cp file1 file2 /home

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
232
Q

command to copy files into a dir that doesnot exist

A

cp -r file /newdir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
233
Q

command to move or rename files

A

mv source destin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
234
Q

command to sort file based on the field no

A

sort -k 10 # 10 is field no

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
235
Q

command to sort file in reverse order

A

sort -r

236
Q

command to sort file uniquely

A

sort -u

237
Q

command to know the disk space used by a file in kilobytes

A

du -k

238
Q

command to know the disk space used by a file in human readable format

A

du -h

239
Q

if u have to gzip a dir by checking it’s file usage on disk

A

du

then 
gzip
then check du
then tar gzip 
and view contents of the tar gzip file
240
Q

When you login you get “$” prompt, what is the prompt for root?

A

#

241
Q

Explain the difference between grep and egrep?

A

egrep is to search for multiple patterns with pattern having a pipe character

eg: egrep “PATTERN1|PATTERN2” FILE

grep is for searching patterns as a string, any special characters are needed to be escaped

eg: grep “PATTERN1|PATTERN2” FILE

242
Q

What are the mostcommon Linux command line tools for parsing files.

A

grep, egrep, sed, awk

243
Q

get a list of all email address with grep

A

$ grep -E -o “\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,6}\b” file.txt

244
Q

Parse a file and print all expressions that match a range between 0.0.0.0 and 999.999.999.999.

A

grep -E -o “([0-9]{1,3}[.]){3}[0-9]{1,3}” file.txt

245
Q

What is the port # for DNS, NTP and NFS?

A

53, 123 and 111/2049

246
Q

What is the configuration file name of DNS and where is it located?
/etc/named.conf

A

All configuration files are located in /etc directory and the name of the DNS configuration file is named.conf.

/etc/named.conf

247
Q

How many new directories will be created after running the following command
mkdir {a..c}{1..3}

A

9

248
Q

Your PC is configured with a DNS server address but not the default gateway. Can the PC access internet?

A

No

249
Q

Can you assign one static IP to 2 computers, if not then why?

A

No because it will create IP conflict

250
Q

You are trying to ping a server by hostname and you get an error message, “ping: unknown host …”. What could be the reason and how to solve the problem so you can ping it by hostname?

A

Check for /etc/hosts or DNS to see if it has hostname to IP entry

251
Q

Explain the difference between relative and absolute path?

A

Absolute path starts from / where relative path is your current directory

252
Q

List 3 different methods of adding user?

A

1) The adduser command automatically creates a home directory and sets the default group, shell, etc. To create a new standard user with the adduser command the syntax is as follows:
sudo adduser bob
2) Anytime you add a user, that user is added to the passwd file,You can edit the file directly or use the commands we will go over shortly - useradd roman
3) useradd bob
passwd

253
Q

What is the command to change file/directory ownership and group?

A

chown and chgrp

254
Q

List any 3 type of filesystem?

A

ext4,
NTFS
FAT

255
Q

What is /bin directory used for?

A

A user of an operating system can expect to find executable files in binary.

256
Q

How to change a user password?

A

passwd username

257
Q

How to logoff from the system?

A

exit

258
Q

Give any 3 examples of operating systems?

A

Windows, Linux and MAC

259
Q

List any 4 linux distributions?

A

Redhat, CentOS, Ubuntu and SUSE

260
Q

How to create a directory?

A

mkdir

261
Q

Where are the zone files located for DNS service?

A

/var/named/zonefiles

262
Q

How to check kernel version?

A

uname –a

263
Q

Which directory has all the configuration files?

A

/etc

264
Q

How to become root user from a regular user?

A

su –

265
Q

What is the purpose of having different network ports?

A

So the communication of each application goes through a dedicated port

266
Q

How to display first column of a file?

A

cat filename | awk ‘{print $1}’

267
Q

What is the name of DNS rpm package?

A

bind

268
Q

How to check a file’s permission?

A

ls –l

269
Q

What is the difference between “kill” and “kill -9” command?

A

kill will create a sigterm signal. kill -9 willforcefull kill the process

270
Q

You are troubleshooting an issue with Redhat support and they have asked you to send the contents of /etc directory. How and which method you will use to transfer the contents?

A

tar (compress) the entire /etc directory and sftp or scp

271
Q

What is root home directory?

A

/root

272
Q

How to check the computer name or host name in Linux?

A

hostname

273
Q

Which permission allows a user to run an executable with the permissions of the owner of that file?

A

First 3 bits should have x

274
Q

What is the command to untar a tarred file?

A

untar

275
Q

What is /proc directory used for?

A

1) provides a method of communication between kernel space and user space.
2) the process reporting utility ps uses the proc file system to obtain its data,
3) special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure

276
Q

List 3 basic commands to navigate the filesystem?

A

cd, pwd and ls

277
Q

Which service/daemon should be running on the server that allows you to connect remotely?

A

sshd

278
Q

What is the purpose of firewall?

A

1) it provides a barrier to control network traffic both into and out of an organization’s Internet-connected network, or perhaps between different segments of an internal network.
2) companies can configure multiple firewalls inside their corporate network to essentially divide the network into multiple segments. That helps contain the damage should some form of worm or other malware be unleashed in any given segment.

279
Q

List any 3 IT components?

A

Hardware, OS and Applications

280
Q

What is the difference between memory, virtual memory and cache?

A

virtual memory: memory in db server or any virtual machine memory
cache: active memeory sits between cpu and memory
physical memory: memory

281
Q

Which directory has all the commands we use, e.g. ls, cd etc.?

A

/usr/bin or /bin

282
Q

Which of the following is a communication command?

A

o grep
o mail this one
o touch
o cd

283
Q

How to rename a file or directory?

A

mv

284
Q

How to change a hostname in Linux?

A

sudo nano /etc/hosts

sudo nano /etc/hostname

285
Q

How to check network interfaces in Linux?

A

ifconfig

286
Q

What command used most often to output all incoming logs in real time

A

“tail –f logfilename”

287
Q

How to sort a file in reverse order?

A

cat filename | sort –r

288
Q

What is the name of operating system that runs Unix?

A

Solaris, HP-UX etc

289
Q

List all byte sizes from smallest to largest?

A

bytes, kilobytes, megabytes,gigabytes,terabytes

290
Q

How to check the total number of partition in Linux?

A

fsdisk -l

291
Q

How to access a linux system from a linux system?

A

ssh

292
Q

What is the exact command syntax to list the 5th column of a file and cut the first 3 letters?

A

cat filename | awk ‘{print $5}’ | cut –c1-3

293
Q

What is /etc/hosts file used for?

A

To resolve hostnames with IP address

294
Q

List any 3 options of ‘df’ command and what they are used for?

A

df -h
df -x tmpfs to exclude certain filesytem types
df -t ext4 list only specific file system types
df -T To show the file system type pass the -T option

295
Q

What is the command to change file/directory permissions?

A

chmod

296
Q

What is the purpose of pipe (|)?

A

To combine multiple commands

297
Q

What is /etc directory used for?

A

For configuration files

298
Q

Which command is used to list files in a directory?

A

ls -l

299
Q

There is a command which gives you information about other commands, please explain that command and what is it used for?

A

man

300
Q

How to delete a file and a directory?

A

rm filename and rmdir dirname

301
Q

What is the difference between “tail” and “tail -10”?

A

None

302
Q

List 4 commands to display or read a file contents?

A

cat, more, less, vi

303
Q

Which command is used to read the top 5 lines of a file?

A

head -5 filename

304
Q

What are the different commands or methods to write to a file?

A

echo > filename and vi filename

305
Q

What is swap space and how to check swap space?

A

top command shows swap space,
swap space is the amount of memory reserved for a process which is equivalent to amount of memory assigned to the process by the kernel., when the physical memory passes its threshold then the swap space is activated,the inactive

306
Q

What is inode and how to find an inode of a file?

A

1) An inode is simply an internal data structure that Linux uses to store information about a filesystem object
2)
ls -id /path/to/dir

i = inode 
d= directory
307
Q

Which file to edit for kernel tuning?

A

1) /etc/sysctl.conf you can configure various Linux networking and system settings

308
Q

Name the command to find specific word from a file?

A

grep word filename

309
Q

You have scheduled a job using crontab but it does not run at the time you specified, what could be the reason and how would you troubleshoot?

A

Check your system time
Check your crontab entry
Check /var/log/messages

310
Q

How to check network interface MAC address?

A

ifconfig

311
Q

If I don’t want others to read my file1, how to do that?

A

Remove r from the last 3 bits of file permission

312
Q

What is the purpose of “uniq” and “sed” command?

A

1) uniq authors.txt, uniq command is of showing a count of occurrences, showing only repeated lines and ignoring characters and specific fields.
uniq -c authors.txt To output the number of occurrences of a line use the -c
uniq -d authors.txt This will output only lines that occur more than once and write the result to standard output
In summary the purpose of uniq is to parse data a

2) sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline).

for eg: 
the input file is 
Tom Westley Essex
Ravi Bopara Essex
Marcus Trescothick Somerset
Joe Root Yorkshire
Jonny Bairstow Yorkshire

uniq -f 2 -c cricketers.txt | sed ‘s/^\s*//’ | cut -d ‘ ‘ -f 1,4

2 Essex
1 Somerset
2 Yorkshire

To ignore fields in a comparison pass the -f option to uniq. This will run the comparison on the specified field and output the result to standard output.

^/s* zero or more occurences of space is replaced by1 single space “ “ to make a solid delimiter for cut command

The cut command in UNIX is a command line utility for cutting sections from each line of files and writing the result to standard output.

In summary, the sed and uniq command are for data transformation.

313
Q

Which command is used to list the contents of a directory in the most recent time and in reverse order, meaning the most updated file should be listed on the bottom?

A

ls –ltr

explanation:

ls -ltr :

  • t option will sort the entries by modification date (with newest first)
  • r will reverse the sorting order.

As -t will sort by modification time with newest first, -r will cause the reverse i.e. oldest entries will be shown first now.

314
Q

What is the difference between tar, gzip and gunzip?

A

Tar is a file archiving technique and it combines mulitple files to a single archive file

gzip is to compression technique to compress a file which has large file

gunzip is to decompress the compressed file that was compressed using the gzip technique

315
Q

How to view difference between two files?

A

diff file1 and file2

316
Q

Run a command that shows all lines except any lines starting with the character # in a file

A

grep -v “^#” filename

317
Q

What is the difference between .bash_profile and basharc

A

.bash_profile is executed when newly logged in to the shell session.

.basharc is executed when already logged in but opened a new trminal

318
Q

The difference between $ and # prompts on CLI

A

$ prompt is for users and # prompt is for root

319
Q

How to create a file

A

touch ,vi

320
Q

Default port number of DNS

A

53

321
Q

name of DNS package name

A

bind

322
Q

configuration file for DNS location

A

/etc/named.conf

323
Q

List 3 type of filesyste

A

ext3,ext4, xfs,fat,ntfs

324
Q

list any 4 unix flavors

A

fedora ubuntu redhat suse

325
Q

hw to find filetype of a file

A

file filename

326
Q

how to check files permission

A

ls -l

327
Q

command to find your current directory

A

pwd

328
Q

how to log off from linux system

A

exit

329
Q

how to check if a package is installed

A

for eg to check if DNS package is installed

rpm -qa | grep bind

330
Q

to check all previously typed commands

A

history

331
Q

how to check where passwd command is located

A

which passwd

332
Q

how to list all the commands

A

ls /usr/bin

333
Q

how to check ip and ac address

A

ifconfig -a

334
Q

How to count no. of lines in a file

A

wc -l filename

335
Q

where is the network time config file located

A

/etc/ntpd.conf

336
Q

how to reboot a linux system with init command

A

init 6

337
Q

when is the last comand used

A

to show last logged in users

338
Q

Can’t write to hard disk on the linux systems?

A

1) Run the df command to find out info about the total space and available space on a file system including partitions
2) Locate the filesystem that has unusually high usage
3) When the disk is full, du on the /var/logs and tar the files where the directory is large on du
4) compress the tar files either usng gzip or bzip technique.
5) Delete unwanted files using rm , and unwanted directories using rmdir
6) Move files to other systems or external hard disk

rsync –remove-source-files -azv /ftp/tmp/*.log /mnt/usbdisk/

rsync –remove-source-files -azv /ftp/tmp/*.log server2:/path/to/the destination/directory

7) find largest dir or files eating disk space on unix system

du -a /ftp/tmp | sort -n -r| head -n 10

8) locate those largest files and truncate the largest files on unix/linux

truncate -s 0 /ftpuser/ftp.log

9)find and remove large files that are open but have been deleted on unix

lsof -np | grep ‘deleted’

10) Check if you are running out of inodes, coz most likely when 1000’s of small files are created on a dir, the ifilesystem runs out of inodes.

To check this out we can use du -i /dirname/filename.ext

if 100 % of inodes are used, we need to find the unwanted files and delete them after transfering them to different server or mount point using rsync command

11) du -hs points to the biggest directory and points to what needs cleaning up

339
Q

Why getting disk full messages on the screen?

A

1) Run the df command to find out info about the total space and available space on a file system including partitions
2) Locate the filesystem that has unusually high usage
3) When the disk is full, du on the /var/logs and tar the files where the directory is large on du
4) compress the tar files either usng gzip or bzip technique.
5) Delete unwanted files using rm , and unwanted directories using rmdir
6) Move files to other systems or external hard disk

rsync –remove-source-files -azv /ftp/tmp/*.log /mnt/usbdisk/

rsync –remove-source-files -azv /ftp/tmp/*.log server2:/path/to/the destination/directory

7) find largest dir or files eating disk space on unix system

du -a /ftp/tmp | sort -n -r| head -n 10

8) locate those largest files and truncate the largest files on unix/linux

truncate -s 0 /ftpuser/ftp.log

9)find and remove large files that are open but have been deleted on unix

lsof -np | grep ‘deleted’

10) Check if you are running out of inodes, coz most likely when 1000’s of small files are created on a dir, the ifilesystem runs out of inodes.

To check this out we can use du -i /dirname/filename.ext

if 100 % of inodes are used, we need to find the unwanted files and delete them after transfering them to different server or mount point using rsync command

11) du -hs points to the biggest directory and points to what needs cleaning up

340
Q

how to solve full/corrupt or failed disk issues?

A

1) Run the df command to find out info about the total space and available space on a file system including partitions
2) Locate the filesystem that has unusually high usage
3) When the disk is full, du on the /var/logs and tar the files where the directory is large on du
4) compress the tar files either usng gzip or bzip technique.
5) Delete unwanted files using rm , and unwanted directories using rmdir
6) Move files to other systems or external hard disk

rsync –remove-source-files -azv /ftp/tmp/*.log /mnt/usbdisk/

rsync –remove-source-files -azv /ftp/tmp/*.log server2:/path/to/the destination/directory

7) find largest dir or files eating disk space on unix system

du -a /ftp/tmp | sort -n -r| head -n 10

8) locate those largest files and truncate the largest files on unix/linux

truncate -s 0 /ftpuser/ftp.log

9)find and remove large files that are open but have been deleted on unix

lsof -np | grep ‘deleted’

10) Check if you are running out of inodes, coz most likely when 1000’s of small files are created on a dir, the ifilesystem runs out of inodes.

To check this out we can use du -i /dirname/filename.ext

if 100 % of inodes are used, we need to find the unwanted files and delete them after transfering them to different server or mount point using rsync command

11) du -hs points to the biggest directory and points to what needs cleaning up

341
Q

One application is connected to 30 Databases using DB connect, there is also a pool limit user , and when that exceeds, the error is pooped us saying pool limit user exceeded or error establishing DB connection .How to trouble shoot it and what causes it ?

A

1) It happens when the query execution time exceeds the normal time
2) There will already by some shell scripts created by primary admin or system admin.
3) So, whenever the application is down, run the scripts
4) if the scripts don’t work, accelerate the issue either to the system admin or the server admin
5) Sometimes the script requires to pass arguments to the scripts, we can either go and edit certain part of the script using the vi editor

342
Q

How to pass arguments to the script just before execution?

A

./shellscript.sh argument1 argument2 argument3 2 “Newyork”

343
Q

How to know the total number of arguments specified to the script

A

$# wil output the number of arguments specified to the script

344
Q

What is shebang?

A

! /usr/bin/prl meaning it should execute using the interpreter specified on a first line

Shebang is a pound symbol followed by an exclamation #!

This syntx is used in scripts to indicate an interpreter for the execution under linux/unix os

for eg #!/bn/bash would mean the shell script should be executed with the bash interpreter

345
Q

what is the difference between sh script and ./script

A

1) Both are used to execute the script
2) Howewer sh scriptname will make it execute under sh
3) ./ could execute under bash/perl/sh/etc whatever interpreter specified in its shebang line

346
Q

How to tackle out of meory alert and why it occurs?

A

Each process is allocated some java heap size for eg 3gig has been alloted to one process

However a user has started downloading a 600 MB excel file and now the process is taking 4GB RAM , then that particular process throws out of memory exception, since it’s demanding more than what’s allocated to it.

The ways to troubleshoot this issue is:

1) If we have a shell script to auto-restart the process, we will go ahead and run it
2) If the process hangs, we will kill it or teminate it

347
Q

Some unexpected behavior on the server side may at times causes real resource outage issues. process crucial to your web application was killed as a result of out of memory situation. How do you troubleshoot it.

A

We have couple of options

1) Reduce amount ofmeory asked by the process
2) Disallow process to overcomit memory
3) Simply add more memory to the server configuration

> A useful memorymonitoring tool is the top command

> If your system memory gets used up to the extent that it can threathen the system stability, the out of memory killer will choose which process to terminate or eliminate and linux keeps a score for each running process for this purpose and it’s called oom score and this score is stored in the file /proc//oom_score

ps aux |grep processname will give the processid
cat /proc/pid/oom_score can give the score, higher the number more likely its can be eliminated.

> Now to change the overcommit mode if the system is at risk of running out of memory,
sudo sysctl -w um.overcomit_memory=2

2 meaning if system doesnt have meomry it will not overcommit
other options include
1 to always allow
0 estimate if we have enough RAM

348
Q

How to know what process runs on which port

A

sudo netstat -tunlp | grep 8080
t = tcp
u =udp
n= numerical display of addresses ,ip and ports
l=list only listening ports
p=show processid and name of the program to which the socket belongs

349
Q

List what files are being used by port 80

A

sudo lsof -i :80

350
Q

Find process nae associated with the pid

A

ps -p 2212 -o -comm=

or

ls -l /proc//exc

351
Q

display the working directory of a process with the pid 123

A

pwdx 123

352
Q

To understand what the command is about

A

whatis pwdx

353
Q

What is the difference between ssh and telnet

A

both are used to connect remotely to the other servers remotely

However, ssh is encrypted version of telnet -
telnet sends data in plain text, if the usecase is for fast protocol,telnet is the choice

if the usecase if for security, ssh is the choice-its a slow protocol due to encryption.

354
Q

Can you troubleshoot what may be causing a connection issue when trying to connect remotely ?

A

1) During establishing connections to other computers firewall issues may be encountered
2) So we need to make sure that port is open in the firewall to listen
3) So wen use telent command to test ports opened or closed on a remote server as follows:
telnet domainnameorIP port

eg. telnet adminuser@google.com 80

Due to security issues of transferring data in plain text most use ssh
4) We can use ping to know if the ip or port are active, but most likely this will be disabled

5) After port issue is established, another issue that can be causing this is ip restriction

ifconfig is to query network interface parameters, using this we can figure out if the ip address is resolved with the particular hostname

355
Q

The system is in trouble , how will you troubleshoot?

A

Will continuously monitor log files for errors, this way I can keep tabs on the live feed of data coming into the log file : var/log/messages
tail -f /var/log/messages

AND use Cntrl C to exit

356
Q

Which is the file where we an go and look for errors

A

/var/log/messages

357
Q

When it’s a really large file particularly because the system is on over the years, which command will u use to view the recently written data

A

I will not use cat command as it can potentially hang the system

I will use the tail -f /varlog/messages

358
Q

How to remove files older than 7 days by creating cronjob to run everynight

A

vi filename

0 0 * * * /bin/find -mtime +7 -exec rm -rf {} ;/

359
Q

How to list all the created users in the system and send the in a file

A

tar -cvf users.tar /etc/passwd | awk ‘{print $1}’ >file.ext
tar -cvf users.tar /etc/passwd | cut d ‘:’ -f 1 >file.ext
sftp file.ext server2:/destination/dir

360
Q

How would you create a file or how to print out the first column of the first field

A

touch or vi used to create a file,

awk and cut can be used to pront out the first column

361
Q

Someone needs data from a file which is really large but only need second column from a file ? how will u do thi

A

cut -d ‘ ‘ -f 2

362
Q

system is about to go down due to some emergency that happened, probably a hack, so it needs to be booted, how to broadcast a message to all the logged in users

A

wall -n “server is going down in 15 mins”

363
Q

How to create a user with no login access because there is an aplication that need a usr account but does not require access to login to a s/m

A

useradd -s /sbin/nologin username

then su username to check

364
Q

Schedule server reboot in 15 minutes

A

shutdown -r 15

365
Q

Schedule server reboot immediately

A

shutdown -r now

366
Q

Schedule server reboot at 11 pm

A

shutdown -r 23:00

367
Q

How to find disk usage by the largest directory

A

this can be troubleshooted by checking disk space pertaining to a particulr user or by particular directory and sub directories

pwd

/var
du -Sh | sort -n | less

S is for searching disk space for directories

368
Q

How to prevent users deleting other users files in a directory

A

This question is pointing towards special permissions that are called sticky bit

chmod 1777 hist/

369
Q

how to display the 10th line of a file only

A

cat filename | head -n 10 | tail -n 1

370
Q

the server got damaged as it got hacked , due to the amount of damage the whole server needs to be restored. How would you go about doing that?

A

There are two parts in this question: Vmware and physical server

1) If I am using VMware and ther is a complete copy of that disk, VM has a tool in it that captures the ystems state off a particular system or depending on which date it’s capturing from , you can completely redo the system from that particular date.

we can restore it from the system state if VMware has saved it to some kind of capture tool that captures the whole system and deploys that image for that system

2) If it’s the physical server , then only the data gets backedup , also some config files can be restored not all.

We can restore the entire OS just from the back up and use the data from the back up taped device

Config files are restored in /etc files

So to summarize , we create a new system, get all the data from the back up and throw them on your new system.

371
Q

To update packages in the server

A

yum update

372
Q

to remove the package

A

yum remove packagename

373
Q

Command to disable service

A

service servicename stop

374
Q

What is the difference between linux and unix

A

Unix was primarily developed with multi tasking and multi users in ind, unix cannot be installed on any hardware. Where as linux can be installed in almost many hardwares and supports may flavors of file system, whereas unix supports only fewer filesystems.

375
Q

What is linux

A

Linux is an operating system sits between hardware and users

376
Q

Difference between linux and windows

A

free not free
not user friendly userfreindly
very secure not so secure
very open to public can modify ur own changes Not an open surce os, cannot open the code or reveal to anyone
Best for multi tasking multi tasking requires high cpu and mem

377
Q

To list all the available ips or interfaces that u have on your system

A

ifconfig command is deprecated,

ip addr

378
Q

What is a filesystem.

A

A filesystem is something similar to your closet at your hoe. Think of each shelf with specific kind of storage. One folder has only programs or applications, another folder have only attaced devices, so it will be much easier for the operating system to access the files,

There are different types of filesystems:
1)ext3
ext4
FAT
NTFS
XFS
379
Q

what command to use to creata ultiple files in a directory

A

touch command
eg:
touch mart lisa tex

380
Q

what command to use to create multiple files in a directory

A

touch command
eg:
touch mart lisa tex

381
Q

what command to use to create multiple directories in a directory

A

mkdir dir1 dir2

382
Q

Tell me what kind of file starts with c

A

if any eboard of mouse is attaches, then that file starts with c

383
Q

Tell me what kind of file starts with p

A

named pipe file starts with p

384
Q

Tell me what kind of file starts with b

A

block device starts with b

385
Q

What are the commands to file diles and directories in a system

A

find and locate

386
Q

How to create files with one command using wildcards

A

touch abcd{1…9}-xyz

this will create 9 files
wildcards are to substitute for charecters

387
Q

touch abcd{1…9}-xyz will create how many files?

A

9 files

388
Q

wildacard used for the begining of the line and the end of the line

A

^ and $ respectively

389
Q

What is soft link and hard link?

A

it is related to inode.

Inode is a pointer of a file on the hard disk

Eevrytime we create a file, computer assisgns a number to the file and hard disk will associate that number to it and that number is called inode

Soft link is a link if when created will be removed if the filname of that link is removed or renamed

once created it looks for the inode through that file, so that creates a soft link, if removed the source file it removes the destination link

whereas for hard link, deleting or renaming the source file will not change the hard link, as if you have copied it

390
Q

What are the commands to create a hard link command

A

ln

391
Q

to create a soft link command

A

ln -s

392
Q

the reason why we creata soft link or hard link

A

to creata shortcut of the actual file, to have easy access instaed of doing a lot directory chnages or specifying the long path to the file

393
Q

Create a soft link to a file in /tmp dir where the file is in /home/hulk

and verify that the link got created

A

cd /tmp
ln -s /home/hulk

to check that the link got created ls -ltr command , at the botto of the output the file is seen

394
Q

Why do we get the error that failed to create a hard link

A

This happens when the hard link is created on the different partition. . For the hard link to work, it needs to be on the same partition.

395
Q

what are file permissions

A

Since unix is a multi user system. typically for protecting our environment where files could be viewed by other users, or unnecessarily modified or deleted by other users

396
Q

how to display directory or file permission , explain them

A

ls -l command,

the first 3 bits are for the user
the second three bits are for the group
the last three bits are for the other users of the system

397
Q

How to remove write permissions of a file for a group

A

chmod g-w filename

398
Q

How to remove read permissions to all users

A

chmod a-r filename

399
Q

How to grant both read and write permissions to user

A

chmod u+rw filename

400
Q

what is the meaning of x in the permissions bits of the direcotry

A

It certainly doesnot mean it is a script, what it means is we cannot cd into that directory

401
Q

commands to change the ownership of the files

A

chown and chgroup that an be changed from the root account

402
Q

let the root user own the filename

A

chown root filename

403
Q

let the root group own the filename

A

chgroup root filename

404
Q

what key completes the command on cli

A

hitting a tab key after the command completes the command

405
Q

to show commands that start with ch

A

type ch and press tab twice

406
Q

To bring the last command that you ran and the commands that were ran previous to it

A

up arrow key

407
Q

Give me the commands that you use to monitor the system

A
top 
free
df
dmesg
netstat 
iostat
cat proc/cpuinfo
cat proc/meminfo
408
Q

What does df report

A

df reports filesystem usage of disk

409
Q

If your system is dead or crashed, one of the things that you will look into it is

A

df command

410
Q

If you see 100 % usage with the df command output,then the next step is

A

to free up the disk space an, and the comand to help in this pursuit is du which will output the disk usage of the files and the directories

411
Q

The command to show you the output of the system related warnings , error messages , failures

A

It throws bunch of messages and bunch of information at you , and that command is
dmesg

If there are any issues with the memory it will report right here , if there is a memory leak, cpu that crashed or any mother board issue, anything related to system hardware will be related to that

412
Q

what command that displays whats coming in and whats coming out and how we are communicating with our system’s peripheral devices or system internal devices if it’s a disk or network

A

iostat

413
Q

Command to find out gateway information, command to find out my subnet mask and what interface it is going through

A

netstat -rnv

414
Q

what is free command used for

A

It gives you information about the virtual memory and the swap space which is a virtual memory utilization

415
Q

What is connected to the system, what is been disconnected , what is the process id and which process is it running and the name of the owner of the process

A

netstat

416
Q

to get all the cpu info- which file to look at

A

cat /proc/cpuinfo

417
Q

what is the log file that stores messages or errors during boot time

A

cat /proc/boot.log |more

418
Q

All the system resouce informations are stored into files, where are these files located?

A

/var/directory

419
Q

what is the log file that stores messages or errors during boot time

A

cat /var/boot.log |more

420
Q

whenever you schedule a job or process through a cron tab entry, that activity is recorded as a log into this file

A

cat /var/cron

421
Q

email out and email in is recorded in which log

A

/var/maillog

422
Q

when troubleshooting issues as to why you are not able to send emails

A

/var/maillogs

423
Q

real time recent logs on users loggin in and logging out

A

tail -f /var/secure

424
Q

everytie there is an issue with the machine, the first thinga an adinistrator does is

A

look into the /var

425
Q

This file has all the hardware information, all the software information, all the application information, all the process information, everything is logged into this log

A

/var/messages

426
Q

command to see how many lines does /var/messages file has

A

cat /var/messages | wc -l

427
Q

which command will give information about the OS and some kernel information

A

uname -a

428
Q

which command will give you the information about the processor memory and the hardware underneath the OS

A

dmidecode

429
Q

the first thing every time who ever logs into the system they should check they should run this command to know about which system they are in

A

uname -a

430
Q

To tell which server you are logged in the command would be

A

hostname

431
Q

how to disable ping

A

go to sysctl.conf

net.ipv4.icmp.ignore_echo_ignore_all = 1

that parameter 1 will disable the ping,
the parameter 0 will enable it

432
Q

explain diff fields in /etc/passwd

A

username uid groupid shellname uid gid home drectory

433
Q

how to know that a port is listening

A

netstat -tunlp | grep 22

434
Q

Which commadn to tell how long the system has been running

A

uptime

435
Q

wat command to show load average on the server

A

uptime

436
Q

Define system load average

A

average number of processes that are in runnable state or uninterrupted state

437
Q

Dispaly all lines in the files with line numbers

A

cat -n filename

438
Q

What is the command to list all the network interfaces

A

ifconfig

439
Q

How to make some congiguration on the network interface specified

A

go to /etc/sysconfig/network-scripts/ifcfg-empos3

440
Q

which command to run to find if certain package is installed

A

rpm -qa | grep packagename

rpm -qa | grep ntp

441
Q

How to find if DNS package is installed or not

A

rpm -qa | grep bind

442
Q

what is rpm command for

A

rpm command is a powerful package manager

443
Q

how to find total lines in a file without opening the file

A

wc -l filename

444
Q

shall we do cat on large files

A

no don’t do cat on large files

445
Q

How to find disk usage of the largest directory

A

du -Sh |sort -nr | head -n 10

446
Q

how to find all directories with name cong under root

A

find / -type d -name conf

447
Q

commadn to view all the currently logged in users

A

who

448
Q

what is SOS report

A

sos repor is a package of all the sysyem congifuration informations, all the processes and all the resources information packaged and send t redhat for support

449
Q

How to combine multiple files into one

A

cat file1 file2 file3 > file4

450
Q

The file is very large, compression is not the option, you need t chop the files to send them to another server or a third party vendor and the log file is huge
how to split single filesinto multiple files

A

split -l 300 filename childfile

451
Q

How to append data to an existing file

A

echo uk&raquo_space;filename

452
Q

To send a foreground running process to background the command is

A

cntrl Z

453
Q

To stop a background process

A

Cntrl C

454
Q

A process when initiated always attaches itself to the terminal from where it is initiated

A

know this?

455
Q

How to not interrupt a background process even after the terminal is closed?

A

nohup processname &

456
Q

How to set priority of a process,

A

nice is the command to set priority of a process, the nice value ranges from -19 to 20, lower the number more priority the task gets.

nice -n process command

457
Q

what is the command to start an applicationand stop an application

A

systemctl restart ntpd

d means daemon

458
Q

what does ntp application do

A

its a daemon and is a network time protocol that runs all the time and syncs your time with other clocks

459
Q

How to know the status of a service

A

systemctl status ntpd

460
Q

To stop a service or an application or a process

A

systemctl stop ntpd

461
Q

To startt an application whenever the system starts the command is

A

systemctl enable ntpd

this will start the ntpd daemon whenevr the system strts

462
Q

How do you know that a process is hung

A

top command that shows 99% of usage of mem and cp

463
Q

command to know no. of users currently logged into the system

A

uptime

464
Q

how to view all the commands available to you as a user

A

cd /usr/bin

ls -l

465
Q

Did you know that you need to sort before u pipe it to uniq command?

A

only then the uniq command works

sort | uniq

466
Q

To get the partition information on the disk

A

fdisk -l

467
Q

Steps to mount new disk to the system

A

1) add new disk
2) initialize the disk
3) Patition the disk
4) mount it to the different mount points

468
Q

what is the purpose of adding a new disk

A

when u run out of the disk space or if you have multiple applications may be one
partition is required for one application and other partiton is required for another application, that’s why we ask new disk

469
Q

what is the purpose of adding a new disk

A

when u run out of the disk space or if you have multiple applications may be one
partition is required for one application and other partition is required for another application, that’s why we ask new disk

470
Q

How to regular zip a directory

A

zip -r filename /path/to/dir/to/zip

471
Q

How to unzip a regular zipped file

A

unzip filename -d dire/where/to/unzip/into

472
Q

what is also another way to monitor cpu usage

A

sar -u

473
Q

how to monitor cpu usage of all cores

A

sar -p ALl

474
Q

How to monitor cpu usage of particular core

A

sar -p 4 (here 4 is the core number)

475
Q

How to monitor the memory free and used

A

sar -r

476
Q

which command shows memory usage ,cpu usage, cpu core usage, i/o statistics, block drivers,run query,load average,netwrok statisitcs

A

sar commadn with it’s different options

477
Q

How to monitor i/o statistics

A

sar -b

478
Q

How to get the historic statistics of the cu usage of 15th of this month

A

sar -u -f /varlog/sa/sa15

479
Q

which command to know the information on number of block drivers

A

sar -d

480
Q

which command to know the information on the run queue and the load average

A

sar -q

481
Q

which command to know the information on the network statistics

A

sar -n

482
Q

which command to show the cpu and i/o of all partitions

A

iostat

483
Q

to show only the cpu utilization bu tnot the partition i/o

A

iostat -c

484
Q

to show only the partition i/o not the cpu

A

iostat -d

485
Q

to show only the info a specified partition device name

A

iostat -p partition-device-name

486
Q

command to display when the system was last rebooted

A

last reboot

487
Q

command to displaywhen the system was last shutdown

A

last shutdown

488
Q

command to display who all logged in to the system on 3rd january 2 am this year

A

last -t 201801030300

489
Q

when did the username =cloudbreak last logged in?

A

last username

490
Q

list all the users currently logged into the system

A

who

491
Q

what is the number of users currently logged into the system

A

who -q

492
Q

when was the system last rebooted

A

who -b

493
Q

what are the processes spawned by the init

A

who -p

494
Q

what are the processes that are dead and their details

A

who -d

495
Q

command to compress a file

A

compress filename

496
Q

command to uncompress a filename

A

compress -rv filename

497
Q

command to know the amount of disk space util

A

df

498
Q

command to know the dis space take up by a specified file say filename

A

du -a filename

499
Q

You noticed that one of the Linux servers has no disk space left, how would you troubleshoot that issue

A

add more disk, create a new partition and link the new partition to an existing file-system

500
Q

How to check Redhat version release?

A

uname -a

501
Q

What is the difference between TCP and UDP?

A

TCP and UDP are protocols used for sending bits of data — known as packets — over the Internet.
The main difference between TCP and UDP is connection; TCP is connection oriented and UDP is connectionless.

TCP is all about reliability—packets sent with TCP are tracked so no data is lost or corrupted in transit

UDP is used when speed is desirable and error correction isn’t necessary. For example, UDP is frequently used for live broadcasts and online games

502
Q

To view the lined between 5 through 10 on file.txt

A

sed -n ‘5,10p’ file.txt

503
Q

to print the entire file except a certain range. To exclude lines 20 through 35 from myfile.txt, do:

A

sed ‘20,35d ‘file.txt’

504
Q

it’s possible that you’re interested in set of non-consecutive lines, or in more than one range. Let’s display lines 5-7 and 10-13 from myfile.txt:

A

sed -n -e ‘5-7p’ -e ‘10-13p’ myfile.txt

505
Q

To replace every instance of the word version with story in myfile.txt, do:

A

sed ‘s/version/story/g’ myfile.txt

506
Q

To replace every instance of the word version with story in myfile.txt, is this command in order to ignore character case

A

sed ‘s/version/story/gi’ myfile.txt

507
Q

replace multiple blank spaces with a single space

A

sed ‘s/ */ /g’ myfile.txt

508
Q

If you’re interested in replacing words only within a line range (30 through 40, for example), you can do

A

sed ‘30,40 s/version/story/g’ myfile.txt

509
Q

Sometimes configuration files are loaded with comments. While this is certainly useful, it may be helpful to display only the configuration directives sometimes if you want to view them all at a glance.

To remove empty lines or those beginning with # from the Apache configuration file, do

A

sed ‘/^##/|^$/|*#/d’ myfile.txt

510
Q

in regular expresion ^$ represnts what

A

blank lines

511
Q

To replace a word beginning with uppercase or lowercase with another word, we can also use

A

sed ‘s/[zZ]ip/rar/g’ file.txt

512
Q

the pattern to search for is Jul 2 at the beginning of each line

A

sed -n ‘/^ Jul 2/p’ file.txt

513
Q

we can also insert spaces (blank lines) for each non-empty line in a file. To insert one blank line every other line in LICENSE, a plain text file

A

sed G file.txt

514
Q

To insert two blank lines, for each non-empty line in a file. do

A

sed ‘G;G’ file.txt

515
Q

replace all instances of this or This (ignoring case) with that in myfile.txt, and we will save the original file as myfile.txt.orig.

A

sed -i ‘.orig’ ‘s/this/that/gi’ myfile.txt

516
Q

you have a file containing full names in the format First name, Last name. To adequately process the file, you may want to switch Last name and First name

A

sed ‘s/^(.)\,(.)/$/2\,/1’ fil.txt

517
Q

we may want to replace start with stop only if the word services is found in the same line. In that scenario, here’s what will happen:

A

sed ‘/services/ s/start/stop/gi’ file.txt

518
Q

Performing two or more substitutions at once

A

sed ‘s/this/that/gi;s/him/her/gi’ file.txt

519
Q

What is a zombie process?

A

To understand what a zombie process is and what causes zombie processes to appear, you’ll need to understand a bit about how processes work on Linux.

When a process dies on Linux, it isn’t all removed from memory immediately — its process descriptor stays in memory (the process descriptor only takes a tiny amount of memory). The process’s status becomes EXIT_ZOMBIE and the process’s parent is notified that its child process has died with the SIGCHLD signal. The parent process is then supposed to execute the wait() system call to read the dead process’s exit status and other information. This allows the parent process to get information from the dead process. After wait() is called, the zombie process is completely removed from memory.

This normally happens very quickly, so you won’t see zombie processes accumulating on your system. However, if a parent process isn’t programmed properly and never calls wait(), its zombie children will stick around in memory until they’re cleaned up.

Utilities like GNOME System Monitor, the top command, and the ps command display zombie processes.

520
Q

How do you search for a pattern/word in a file and then replace it in an entire file?

A

sed ‘s/patter/replcer/gi’ filename

521
Q

Explain the purpose of “touch” command?

A

To create an empty file

522
Q

If a command hangs, how to stop it and get the prompt back?

A

Ctrl C

523
Q

Which command is used to count words or lines?

A

wc

524
Q

How to check the number of users logged in?

A

who

525
Q

What is the command to view the calendar of 2011?

A

cal 2011

526
Q

Which command is used to view disk space?

A

df –h

527
Q

How to create a new group in Linux?

A

groupadd

528
Q

What is the command to send a message to everyone who is logged into the system?

A

wall

529
Q

Which command is used to check total number of disks?

A

fdisk –l

530
Q

What does the following command line do?

ps -ef | awk ‘{print $1}’ | sort | uniq

A

print all the processes and only print the first column of all running processes and sort them and remove duplicates

531
Q

. You get a call that when a user goes to www.yourwebsite.com it fails and gets an error, how do you troubleshoot?

A

Check for user internet
Check to see if user computer has DNS for hostname lookup
Check to see if the server is up that is running that website
Check to see if the server’s web service is running
Check for DNS availability which is resolving that website

532
Q
  1. List 4 different directories in /?
A

/etc, /bin, /tmp, /home

533
Q

What is the output of the following command: $tail -10 filename | head -1

A

It will show the first line from the last 10 lines of a file

534
Q

What are the different fields in /etc/passwd file?

A

username passwword uid group name group id fullname of the user user home directory user terminall login

535
Q
  1. What is the difference between “hostname” and “uname” commands?
A

Hostname will give you system name and uname will give you OS information

536
Q

How to check system load?

A

top and uptime command

537
Q

How to schedule jobs?

A

crontab

538
Q

What is the 3rd field when setting up crontab?

A

Day of the month

539
Q
  1. What is the command to create a new user?
A

useradd

540
Q
  1. What is the “init #” for system reboot?
A

6

541
Q
  1. How to restart a service?
A

systemctl restart servicename

542
Q
  1. How to shutdown a system?

shutdown or init 0

A

shutdown or init 0

543
Q

How to shutdown a system?

shutdown or init 0

A

shutdown or init 0

544
Q

What is “ftp” command used for?

A

To transfer files from one computer to another

545
Q
  1. How to delete a package in Linux?
A

rpm –e packagename

546
Q
  1. What is the file name where user password information is saved?
A

/etc/shadow

547
Q
  1. Which command you would use to find the location of chmod command?
A

which chmod

548
Q
  1. Which command is used to check if the other computer is online?
A

ping othercomputer

549
Q

Please explain about LAN, MAN and WAN

A

A LAN (Local Area Network) is a group of computers and the network devices connected together usually within the same building. By definition, the connections must be high-speed and relatively inexpensive (e.g. token ring or Ethernet). A “LAN Connection” is a high-speed connection to a LAN. See “What is a LAN (local area network)?” below.

A MAN (Metropolitan Area Network) is a larger network that usually spans several buildings in the same city or town.

A WAN (Wide Area Network) is, in comparison, not restricted to a geographical location, although it might be confined within the bounds of a state or a country. A WAN connects several LANs, and may be limited to an enterprise (a corporation or an organization) or accessible to the public. The technology is high-speed, and is relatively expensive. The Internet is an example of a worldwide public WAN.

550
Q

How to list hidden files in a directory?

A

ls –la

551
Q
  1. What is the difference between telnet and ssh?
A

ssh is secure where telnet is not

552
Q
  1. How to run a calculator on Linux and exit out of it?
A

bc and quit

553
Q
  1. List any 4 commands to monitor system?
A

top, df –h, iostat, dmesg

554
Q
  1. You are notified that your server is down, list the steps you will take to troubleshoot?
A

Check the system physically
Login through system console
Ping the system
Reboot or boot if possible

555
Q
  1. What is difference between static and DHCP IP?
A

A Static IP address is a dedicated IP address that has been assigned to you. This is an IP address that is used by you every time you log in to network and need an IP address. DHCP or Dynamic is an IP address that will automatically be chosen for you from a pool of IP addresses that are assigned in the DHCP scope available on your network. Think Static as permanent and DHCP as temporary.

556
Q
  1. How to write in vi editor mode?
A

i = insert, a = insert in next space, o = insert in new line

557
Q
  1. What is the difference between “crontab” and “at” jobs?
A

crontab is for repetitive jobs where at is for one time job

558
Q
  1. What is “dmidecode” command used for?
A

To get system information

559
Q
  1. What is the location of system logs? E.g. messages
A

/var/log directory

560
Q
  1. How to setup an alias and what is it used for?
A

alias aliasname=”command”

It is used to created short-cuts for long commands

561
Q

what is the purpose of netstat

A

Netstat is a common command line TCP/IP networking utility available in most versions of Windows, Linux, UNIX and other operating systems. Netstat provides information and statistics about protocols in use and current TCP/IP network connections.

netstat (network statistics) is a command line tool for monitoring network connections both incoming and outgoing as well as viewing routing tables, interface statistics etc. netstat is available on all Unix-like Operating Systems and also available on Windows OS as well

562
Q

What is nslookup used for

A

to resolve dns to obtain dns or ip addreses mapping for any other specific dns record

563
Q
  1. What are terminal control keys, list any 3?
A

Crtl C, D and Z, tab and up arrow

564
Q
  1. Which command(s) you would run if you need to find out how many processes are running on your system?
A

ps -ef |awk ‘{print $1}’ |sort |uniq|wc -l or simply

ps -ef |wc -l

565
Q
  1. What are the different types of shells?
A

sh, bash, ksh, csh etc.

566
Q
  1. How to delete a line when in vi editor mode?
A

dd

567
Q
  1. Which is the core of the operating system?
A

a) Shell
b) Kernel«
c) Commands
d) Script

568
Q
  1. Which among the following interacts directly with system hardware?
A

a) Shell
b) Commands
c) Kernel«
d) Applications

569
Q
  1. How to save and quit from vi editor?
A

Shift ZZ or :wq!

570
Q
  1. What is the difference between a process and daemon?
A

A daemon is just a term for a process that runs continuously and usually is not attached to a terminal

571
Q
  1. What is the process or daemon name for NTP?
A

ntpd

572
Q
  1. What are a few commands you would run if your system is running slow?
A

top, iostat, df –h, netstat etc.

573
Q
  1. How to install a package in Redhat Linux?
A

yum install packagename

574
Q
  1. What is the difference between “ifconfig” and “ipconfig” commands?
    i
A

ifconfig for Linux and ipconfig for Windows

575
Q
  1. What is the first line written in a shell script?
A

Define shell

e.g. #!/bin/bash

576
Q
  1. Where is the network (Ethernet) file located, please provide exact directory location and file name?
A

/etc/sysconfig/network-scripts/ifcfg-nic

577
Q
  1. Why do we use “last” command?

To see who has logged in the system whether active or logged off

A

To see who has logged in the system whether active or logged off

578
Q
  1. To view your command history, which command is used and how to run a specific command?
A

history and history #

579
Q
  1. What is the difference between domain and nameserver?
A

The server or usually called as web server is an actual place where your website files are hosted. … The domain name is a pointer to an IP address which hosts a server. Think of it as the difference between the street address “Example Street 42” (the domain name) and the house on that address (the server).

580
Q
  1. How to check scheduled jobs?
A

crontab –l

581
Q
  1. How to check system memory and CPU usage?
A

free and top

582
Q
  1. Which utility could you use to repair the corrupted file system?
A

fsck

583
Q
  1. What is the command to make a service start at boot?
A

systemctl enable servicename

584
Q
  1. How to combine 2 files into 1? E.g. you 3 lines in file “A” and 5 lines in file “B”, which command syntax to use that will combine into one file of 3+5 = 8 lines
A

cat fileA&raquo_space; fileB

585
Q
  1. What is echo command used for?
A

To output to a screen

586
Q
  1. Which file to modify to allow users to run root commands
A

/etc/sudoers

587
Q
  1. Your system crashed and being restarted, but a message appears, indicating that the operating system cannot be found. What is the most likely cause of the problem?
A

The /boot file is most likely corrupted