0% found this document useful (0 votes)
39 views18 pages

Linux Cmds

The document discusses various commands used for searching, viewing, and managing files and processes in Linux. It describes the find command for searching files, grep for searching patterns within files, and killall for terminating processes by name. It also covers commands for viewing file contents like cat, getting command documentation with man, changing directories with cd, creating and deleting files and directories with touch, mkdir, rmdir, and rm. Finally, it mentions commands for viewing process information like ps and terminating processes using kill along with the PID.

Uploaded by

ZeyRoX Gaming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views18 pages

Linux Cmds

The document discusses various commands used for searching, viewing, and managing files and processes in Linux. It describes the find command for searching files, grep for searching patterns within files, and killall for terminating processes by name. It also covers commands for viewing file contents like cat, getting command documentation with man, changing directories with cd, creating and deleting files and directories with touch, mkdir, rmdir, and rm. Finally, it mentions commands for viewing process information like ps and terminating processes using kill along with the PID.

Uploaded by

ZeyRoX Gaming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Searching the File System

• Use command- find


– It search for files in a directory hierarchy under Linux and
all other UNIX like operating systems.
– Examples:
• find . - name thisfile.txt. ...
• find /home -name *.jpg. Look for all . ...

www.lpu.in Lovely Professional University


1
Searching the File System contd..
Use command- grep
• grep is an acronym that stands for Global Regular Expression
Print.
The grep command searches through the file, looking for matches to
the pattern specified.
Grep is case-sensitive.

Example:
grep myname biodata
• Here biodata is file and myname is specific pattern for searching in
biodata file

www.lpu.in Lovely Professional University


2
Use of grep

www.lpu.in Lovely Professional University


3
Use of grep contd..

www.lpu.in Lovely Professional University


4
Kill command
– The killall is a Linux only command. It kills processes by names.
– Examples:
• killall {Process-Name-Here}
• killall -9 {Process-Name-Here}
• killall -15 {Process-Name-Here}
• kill the process using a PID (Process ID)
– # kill 3486
PID can be searched using pgrep command

www.lpu.in Lovely Professional University


5
Path Variable
• It displays or set a search path for executable files at the command line.
• Syntax PATH pathname [;pathname] [;pathname] [;pathname]... PATH
PATH ; Key pathname : drive letter and/or folder ; : the command 'PATH ;'
will clear the path PATH without parameters will display the current path.
• The %PATH% environment variable contains a list of folders.

• The PATH variable is an environment variable containing an ordered


list of paths that Linux will search for executables when running a
command.
– For example, if we want to print Hello, world! in Bash, the command 
echo can be used rather than /bin/echo, so long as /bin is in PATH:

www.lpu.in Lovely Professional University


6
Adding/Deleting a Path
• Using the export command, new path can be added.

www.lpu.in Lovely Professional University


7
• Activity

• Add to the path in Windows

www.lpu.in Lovely Professional University


8
Other Shell Commands:
• ls • rmdir
• cat • mkdir
• man • rm
• cd • chmod
• touch • pwd
• cp • ps
• mv • kill

www.lpu.in Lovely Professional University


9
ls command
• The ls command is used to list files or directories in Linux and other Unix-
based operating systems.
• Use of ls command as below:

www.lpu.in Lovely Professional University


10
cat command
• Outputs the contents of a text file.
• You can use it to read brief files or to concatenate files together.
• To append file1 onto the end of file2, enter:
• cat file1 >> file2
• To view the contents of a file named myfile, enter:
• cat myfile

www.lpu.in Lovely Professional University


11
man command
• The man command is a built-in manual for using Linux commands.
• Displays the user manual of any command that we can run on the terminal.
It provides a detailed view of the command which includes NAME,
SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN
VALUES, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS.
• Basic Symbol

• option – the search result output.


• section number – the section in which to look for the man page.
• command name – the name of the command which man page you want to
see.
www.lpu.in Lovely Professional University
12
cd command
• It changes your current directory location.
• By default, your Unix login session begins in your home directory.
• To switch to a subdirectory (of the current directory) named myfiles, enter:
• cd myfiles
• To switch to a directory named /home/dvader/empire_docs, enter:
• cd /home/dvader/empire_docs

www.lpu.in Lovely Professional University


13
Touch
The touch command's
primary function is to
modify a timestamp.

www.lpu.in Lovely Professional University


14
cp
• This command copies a file, preserving the original and creating an
identical copy.
– cp -i oldfile newfile
mv
mv stands for move.
mv is used to move one or more files or directories from one place to
another in a file system like UNIX.
Use it as:
mv [Option] source destination 

chmod
• This command changes the permission information associated with a
file.
www.lpu.in Lovely Professional University
15
Mkdir
• The mkdir command is used to create (or make) a directory.
• Example:
• # mkdir LPUCSE

rmdir
• The rmdir directory is used to remove directories, but only those that are
empty (i.e., contain no files or subdirectories). In order to delete a directory
with actual contents, you must use the rm -R command.
• Example
• To remove an empty directory:
• # rmdir /mike

www.lpu.in Lovely Professional University


16
Rm
Use the rm command to remove files you no longer need.
Example
Removing one file at a time
$ rm CSEA.txt

Pwd
Simply type pwd into your terminal, and the command will output the
absolute path of your print working directory.
The pwd command writes to standard output the full path name of your
current directory (from the root directory). All directories are separated by
a / (slash). The root directory is represented by the first /, and the last
directory named is your current directory.
The ps command, short for Process Status, is a command line utility that is
used to display or view information related to the processes running in a
www.lpu.in
Linux system. Lovely Professional University
17
ps
The ps command, short for Process Status, is a command line utility that is
used to display or view information related to the processes running in a
Linux system.

kill
kill command in Linux (located in /bin/kill), is a built-in command which is
used to terminate processes manually.

www.lpu.in Lovely Professional University


18

You might also like