Basic Commands for Linux


Following are the basic commands used to operate linux:

man <command>  ­-  shows all information about the command

<command> ­­help - ­ shows the available options for that command

File/Directory Handling Commands

mkdir – make directories

Example:

mkdir Project

ls – list directory contents

Example:

ls etc

cd - changes directories

Example:

cd Project

pwd – print name of current working directory

vim – Vi Improved, a programmers text editor

Example:

vim Project/code.txt

 cp – copy files and directories

Example:

cp code.txt code_copy.txt
cp code_copy.txt target_dir_name

mv – move (rename) files

Example:

mv source_code.txt target_dir_name
mv source_code.txt new_source_code.txt

rm – ­ remove files or directories

Example:

rm code.txt

find – search for files in a directory hierarchy

Example:

find code.txt

history – prints recently used commands

Text Processing Commands

cat – concatenate files and print on the standard output

Example:

cat source.txt class.txt
cat -­n source.txt

echo - display a line of text

Example:

echo Hello World!

grep – print lines matching a pattern

Example:

grep ­i searchkeyword text.txt

wc – print the number of newlines, words, and bytes in files

Example:

wc source.txt

sort – sort lines of text files

Example:

sort source.txt

System Administration Commands

chmod –  change file access permissions

Example:

chmod 744 execute_com.sh

chown – change file owner and group

Usage: chown [OPTION]… OWNER[:[GROUP]] FILE…

Example:

chown root source.txt

su - change user ID or become super­user

Example:

su sysuser, su

passwd –  update  a user’s authentication tokens(s)

who -  show who is logged on

ps – report a snapshot of the current processes

kill – to kill a process(using signal mechanism)

Usage: kill [OPTION] pid

Example:

kill 2275

Archival Commands

tar – to archive a file

Example:

tar ­xvf /var/archive.tar

zip – package and compress (archive) files

Example:

zip file_folder.zip file_folder

unzip – list, test and extract compressed files in a ZIP archive

Example:

unzip file_folder.zip

Advanced Commands

reboot – reboot the system

poweroff -  power off the system

Tags: , ,

Comments & Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

*


3 × = 3

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>