LINUX Practical Exam
LINUX Practical Exam
LINUX Practical Exam
*$help - help command as told before just displays information about shell built-in
commands.
*each man page some discription attached to it, this description of man page is
found out by:
$whatis ls (-d : to print debugging info., -r, -w, -l(avoid truncated output), -s,
-m)
*$date: displays date only root user can change the date of the system
how to set date: $date --set="Tue Nov 13 15:23:34 PDT 2018"
*$whoami: It displays the username of the current user when this command is
invoked.
$whoami --help
$whoami --version
w - who is looged in and what they are doing
- This command shows the information about the users currently on the machine and
their processes.
$w -h: dont print header
$w -u: ignore username
$w -i: print ip addresses too
*calendar: $cal
$cal 2020
$cal 08 2020
*Aliases allow a string to be substituted for a word when it is used as the first
word of a simple command.
$ alias cls='clear'
Use the alias
$ cls
*$less filename: less is a command that displays file contents or command output
one page at a time in your terminal.
less is most useful for viewing the content of large files or the results of
commands that produce many lines of output.
*stdin, stdout, and stderr are three data streams created when you launch a Linux
command.
--In Linux, every file and every directory are owned by a single user on that
system.
--Each file and directory also has a security group associated with it that has
access rights to the file or directory.
--If a user is not the directory or file owner nor assigned to the security group
for the file, that user is classified as other and may still have certain rights to
access the file.
--Each of the three file access categories, owner, group, and other, has a set of
three access permissions associated with it.
--The access permissions are read, write, and execute.
++Permission Groups
Each file and directory has three user based permission groups:
Owner - The Owner permissions apply only the owner of the file or directory, they
will not impact the actions of other users.
Group - The Group permissions apply only to the group that has been assigned to the
file or directory, they will not affect the actions of other users.
All users - The All Users permissions apply to all other users on the system, this
is the permission group that you want to watch the most.
++Permission Types
Read - The Read permission refers to a user's capability to read the contents of
the file.
*inode: metadata about a file is managed with a data structure known as an inode
(index node).
*mount & unmount: mount command is used to mount the filesystem found on a device
to big tree structure(Linux filesystem) rooted at ‘/‘. Conversely, another command
umount can be used to detach these devices from the Tree.
*nice--priority of processes
*renice--changes priority of already running process
*df--free disk space
*kill--process kill should know about the pidof process
*PS--process status
*TOP--all currently running processes
*free--shows free and used memory
*bg--to send process in the background
*fg--to stop process in foreground
*grep: grep stands for global regular expression print. It is a family of programs
that is used to search the input file for all lines that match a specified regular
expression and write them to the standard output file (monitor).
grep [options] pattern [files]
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,
*awk: Awk is a scripting language used for manipulating data and generating
reports.The awk command programming language requires no compiling, and allows the
user to use variables, numeric functions, string functions, and logical operators.
Useful For:
(a) Transform data files
(b) Produce formatted reports
*sed: SED command in UNIX is stands for stream editor and it can perform lot’s of
function on file like, searching, find and replace, insertion or deletion.
-- By using SED you can edit files even without opening it, which is much quicker
way to find and replace something in file, than first opening that file in VI
Editor and then changing it.
$sed 's/unix/linux/' geekfile.txt
*head: The head command, as the name implies, print the top N number of data of the
given input. By default, it prints the first 10 lines of the specified files.
$ head state.txt
*tail: The tail command, as the name implies, print the last N number of data of
the given input. By default it prints the last 10 lines of the specified files.
$ tail -n 3 state.txt