2 - Familiarisation of Linux Commands
2 - Familiarisation of Linux Commands
PROBLEM DEFINITION
Study of Unix/Linux general purpose utility command list obtained from (man, who, cat, cd, cp, ps,
ls, mv, rm, mkdir, rmdir, echo, more, date, time, kill, history, chmod, chown, finger, pwd, cal,
logout, shutdown, grep, mount)commands.
-A, --show-all
equivalent to -vET
-b, --number-nonblank
number nonempty output lines, overrides -n
-e equivalent to -vE
-E, --show-ends
display $ at end of each line
-n, --number
number all output lines
4. cd -
The cd (“change directory”) command is used to change the current working directory in
Linux and other Unix-like operating systems.The current working directory is the directory
(folder) in which the user is currently working in. Each time you interact with your
command prompt, you are working within a directory.
cd [OPTIONS] directory
The command accepts only two options that are rarely used.
−L, Follow symbolic links . By default, cd behaves as if -L option is specified.
−P, Don’t follow symbolic links. In other words, when this option is specified, and you try to
navigate to a symlink that points to a directory, cd will change into the directory.
ls /applications
will show the user all of the folders stored in the overall applications folder. The lscommand
is used for viewing files, folders and directories.
20. Finger command is a user information lookup command which gives details of all
the users logged in. This tool is generally used by system administrators. It provides
details like login name, user name, idle time, login time, and in some cases their
email address even.
21. pwd - print name of current/working directory
Print the full filename of the current working directory.
-L, --logical
use PWD from environment, even if it contains symlinks
-P, --physical
avoid all symlinks
The function logout() clears the entry in the utmp file again.
In addition, the variant programs egrep, fgrep and rgrep are the same as grep -E,
grep -F, and grep -r, respectively. These variants are deprecated, but are provided
for backward compatibility.
Options Description
-c : This prints only a count of the lines that match a
pattern
-h : Display the matched lines, but do not display the
filenames.
-i : Ignores, case for matching
-l : Displays list of a filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not matches the
pattern
-e exp : Specifies expression with this option. Can use
multiple times.
-f file : Takes patterns from file, one per line.
-E : Treats pattern as an extended regular expression (ERE)
-w : Match whole word
-o : Print only the matched parts of a matching line,
with each such part on a separate output line.
-A n : Prints searched line and nlines after the result.
-B n : Prints searched line and n line before the result.
-C n : Prints searched line and n lines after before the
result.
$grep -i "UNix" geekfile.txt
The -i option enables to search for a string case
insensitively in the give file. It matches the words like
“UNIX”, “Unix”, “unix”.
Conclusion
Study of various Unix/Linux general purpose utility command has been done and exapmples of the
same commands are used successfully.