Linux or Ubuntu Commands PDF
Linux or Ubuntu Commands PDF
less /etc/ passwd -----> To check the contents of a text file one screen at a time (in the path)
q -----------------------> quit
------------------------------------------------> Filter commands <---------------------------------------------
grep ---------------> find the file or directory with details (ls -l | grep filename)
grep -i ---------------> find the file or directory with details ignore the case sensitive
Symbolic method:-
chmod u-rxw filename --------> change the permissions of your file or directory user level
chmod g-rxw filename --------> change the permissions of your file or directory group level
chmod o-rxw filename --------> change the permissions of your file or directory Other level
-:Absolute method:-
chmod 471 filename --------> change the permissions of your files or directory
Hear 471
1. symbolic method.
2. Absolute method.
=======================
1. symbolic method.
sudo apt get update ----------> update the package index files on the system, which contain
information about available packages and their versions
Ping ---------> To check connectivity between two nodes [ex:- ping google.com]
traceroute ------------> Network troubleshooting utility or To check the host name and ip address
ps -----------------> used to list the currently running processes and their PIDs along with some other
information
Kill ----> This is syntax kill -9 1212 (-9 here is forcefully, 1212 here is PID)
Top ----> show the active Linux processes or displays all the running process within the environment of
your system
Ctrl + c -----------> Interrupting the current Process or exiting the current process or the terminal sends
an interrupt signal (SIGINT) to the process, causing it to stop immediately
df -----------> displays information about total space and available space on a file system (or) to display
the disk space used in the file system.
du -------------> Disk usage (or) The du (disk usage) command measures the disk space occupied by files
or directories It is like a task manager in window
Node = server = Clint =--> A point of intersection/connection within a data communication network
Interfaces = cables --> the point of connection between a computer and a network
traceroute google.com ----------> traceroute domain.com ---> To display how the data transmitted from
a local machine to a remote machine
netstat -r ----------> To show network status (for Ref:- https://phoenixnap.com/kb/netstat-command)
dig ---------------> Dig (Domain Information Groper) performs DNS lookup by querying name servers
and displaying the result to you
tar ----> used for saving several files into an archive file/tar Command to Compress Files in Linux
(Or)
date ------------> display and set the system date and time
man ls ----------------> This will display detailed information about the “ls” command, including its
usage, options, and examples.
-----------> Ascending and Dissending order inside the content of file or folder content <-----------------
Sed ---------> sed(stream editor)--> search a word in file, replace it with other word
Note:- it will only modify the o/p, but there will be no change in original file
Sed ‘s/ansible/Linux/’ file1 ---> (s) means search here), (ansible) is existing word in a file here),(replace
the anisble with Linux here), (file1) is
filename)
Sed ‘s/ansible/Linux/ig’ file1 ---> (i) is here use to ignore the case-sensitive
Sed -n ‘5, 10p’ file1 ---> (n) is here is number ) --> I want to show the 5 to 10 lines
Sed ‘5, 10d’ file1 ---> (d) is here is delete ) --> I want to delete the 5 to 10 lines in a file
find . -mtime -1 -print --> $ find . -mtime -1 the . is the search path -mtime time parameter -1 list files
modified in the last 24 hours
-1 the last 24 hours -0.5 the last 12 hours -0.25 the last 6 hours +3 more
than three days
awk command ------> uses a set of user-supplied instructions to compare a set of files, one line at a
time, to extended regular expressions supplied by the user.
cat awk | awk '{print $2}' --> '{print $2}' means print the second field
333 cat awk | awk '{print $1}' --> '{print $1}' means print the first field
334 ls -l
335 cat awk | awk '{print $1, $4}' --> The $1 represents the first input field (first column), and the $4
represents the forth
336 cat awk | awk '{print $1, $NR}' --> NR: It is used to show the current count of the lines
339 cat awk | awk '{print $1,$NF}' --> NF is a predefined variable whose value is the number of
fields in the current record.
Uniq ------------------> A command-line utility that helps you filter out repeated lines in a file
cat bala1 | uniq -c -----------> A command-line utility that helps you filter out repeated lines in a file
What is the difference between uniq and sort in Linux?
The sort command orders a list of items both alphabetically and numerically, whereas the uniq
command removes adjacent duplicate lines in a list.
rm Deletes a file
alias and unalias Sets and removes an alias for a file or command