Linux Commands For Exams

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Friday, 19 February 2016

LINUX Commands
Basic Linux commands and their options
I.

grep : Used for pattern searching in a file


A. Options: -c only count of the selected lines is written to
standard o/p
B. -i : Performs Case insensitive matching. By default grep is
case sensitive
C. -n : Includes the line number with the o/p lines
D. -r : Recursively search all the subdirectories listed

II. cat : Reads file sequentially and writes them to the standard
output. Also used to take input from the standard input and
redirect into a file. Terminated with Ctrl-L

J
N
O
C

A. -b : Number the non blank output lines

B. -n : Number the lines of the file on the o/p screen including


the blank lines

C. -s : Squeeze multiple blank lines such that there is only a


blank line in between
III. ls : Listing the files and directories of the current directory (i.e.
pwd)
A. -1 : Forces the output to be a single entry per line
B. -a : Also includes directories that start with (.) i.e hidden
files

Friday, 19 February 2016

C. -l : List in long format. All information like file permissions


are displayed on the standard o/p
D. -m : List files in the CSV format i.e Comma Separated
Version
E. -t : Sort by time modified i.e recent files first
IV. cd : Used for changing the directories from the pwd
V. bc : Used for calculation and similar stuffs
A. -q : Does not print the usual bc welcome statement
B. -i : Force the interactive mode ON
C. -v : Prints out the version of the bc on the system
VI. cp : Used for copying a source file into the destination file.
Doesn't work if the source file is not present

J
N
O
C
S

A. -f : Forced option. If the destination file doesn't allow write


option this option creates a new file, removes the old file and
copy the contents without prompting
B. -i : Forces the command to go into interactive mode i.e it
asks for permission to overwrite the file.
C. -v : Uses the verbose mode. Shows the file as they are being
copied.
D. -p : Preserve the file attributes like file modification time etc.
VII.chmod : Changing the file access permissions
A. -f : Dont prompt the user with error message if the
command fails
B. -h : Changing the mode of the symbolic link rather than the
file it points to
2

Friday, 19 February 2016

C. -R : Change the permissions of both the directory as well as


the subdirectories of the file
VIII.who : Prints out the information of the user who is logged in
A. -b : Prints out the time and date of last system reboot
B. -h : Writes column heading above the output
C. -m : Only print the information of the current terminal
system which the user is working on
D. ami : Invokes the users real name

J
N
O
C
S

IX. echo : Writes the arguments give to the standard output. The
output can be redirected to any file using the output/input
redirection methods.
X. cmp : Compare two files byte by byte. The differences line and
column numbers if any encountered in the file are printed on
the standard output
A. -b : Print the differing bytes
B. -n : Compare at most n number of bytes
C. -s : Output nothing, only exit status
XI. head : Displays first 10 lines of the file
A. -n : Displays the n number of lines of the file
B. -c : Displays the c number of bytes of the file
XII.tail : Displays the last 10 lines (by default) of the file
A. -n : Displays the last n lines of the file
B. -c : Displays the last c bytes of the file

Friday, 19 February 2016

XIII.sort : Sorting and concatenating the files and print the output
on the standard output
A. -b : Ignoring the leading blanks
B. -f : Ignore the case of the letter
C. -n : Numeric sort
D. -r : Reverse the sorted output
E. -o file : Write the result to the output file
XIV.tee : This command copies standard input to standard output,
making a copy of it in zero or more files. Basically it divides
the standard input into any number of streams, one of the
streams being the terminal screen

J
N
O
C

A. -a : append the output to the files rather than overwriting


them

XV.wc : Displays the number of lines, words, bytes contained in a


file.
A. -l : Displays the number of lines of the i/p file
B. -w : Displays the number of words of the i/p file
C. -c : Prints out the number of bytes of the i/p file

You might also like