Nothing Special   »   [go: up one dir, main page]

LINUX Practical Exam

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

GNU is open source OS, and contain a whole bunch of softwares

GPL - Genral Public lisence(open,use,share,madify,study)


Principles: modularity, simplicity,

*$help - help command as told before just displays information about shell built-in
commands.

*manual page/ man page: is a documentation manual of diff. commands available in


lunix operating systems.
man printf
man command in Linux is used to display the user manual of any command that we can
run on the terminal.
(manual)Executable programs, system calls, library calls, special files, etc
contained
-a option: This option helps us to display all the available intro manual
pages in succession.
Section-num: Since a manual is divided into multiple sections so this option
is used to display only a specific section of a manual.

*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

*$who - Report which users are logged in to the system.


1. Time of last system boot
2. Current run level of the system
3. List of logged in users and more.
4. Login time of the users in to system
$who -m -h : host name associated with stand. I/P

*calendar: $cal
$cal 2020
$cal 08 2020

*bc: bc command is used for command line calculator. It is similar to basic


calculator
$ echo "12+5" | bc

*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.

*$pwd: Finding Where You Are with the “pwd” Command


*$ls: Finding what is in this directory
*$ls -l(long O/P): Extended detailed things
*$ls -a: To get all files including hidden files
*$cd: Go back to the home directory
*$cd /user/test: moving around directory
*$touch file_name: Create a file with touch command
*$mkdir: create directory with mkdir
if any parent directory is absent while $mkdir -p user/abhi/test (-p will
make it)
*$mv file1(filenm) test(directory): move any file in a specific directory or
renaming
*$cp file1 file2: copying file & directories with cp
*$rm: removing files
*$rmdir: removing directory

*stdin, stdout, and stderr are three data streams created when you launch a Linux
command.

*File Security Model

--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.

--Basic File Permissions

++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

Each file or directory has three basic permission types:

Read - The Read permission refers to a user's capability to read the contents of
the file.

Write - The Write permissions refer to a user's capability to write or modify a


file or directory.
Execute - The Execute permission affects a user's capability to execute a file or
view the contents of a directory.

*$chmod u+r assgn1_client


u-owner then operator command to add(+), remove(-), =
o-others
g-group
a-all

*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

*wc: wc stands for word count.


It is used to find out number of lines, word count, byte and characters count in
the files specified in the file arguments.
By default it displays four-columnar output.
First column shows number of lines present in a file specified, second column shows
number of words present in the file, third column shows number of characters
present in file and fourth column itself is the file name which are given as
argument.

*There are two types of links :

Soft Link or Symbolic links


Hard Links
These links behave differently when the source of the link (what is being linked
to) is moved or removed. Symbolic links are not updated (they merely contain a
string which is the pathname of its target); hard links always refer to the source,
even if moved or removed.

You might also like