You are on page 1of 18

LINUX COMMANDS

INTRODUCTION TO LINUX: Linux is a Unix-like operating system that was


designed to provide personal computer users a free or very low-cost operating
system comparable to traditional and usually more expensive Unix systems. Linux
has a reputation as a very efficient and fast-performing system. Linux's kernel (the
central part of the operating system) was developed by Linus Torvalds at the
University of Helsinki in Finland. To complete the operating system, Torvalds and
other team members made use of system components developed by members of
the Free Software Foundation for the GNU Project.

BASIC LINUX COMMANDS
1.bc COMMAND:
bc command is used for command line calculator. It is similar to basic
calculator. By using which we can do basic mathematical calculations.

SYNTAX:
The Syntax is
bc [options]
2.cal COMMAND:
cal command is used to display the calendar.

SYNTAX:
The Syntax is
cal [options] [month] [year]

3.clear COMMAND:
This command clears the terminal screen.

SYNTAX:
The Syntax is
Clear

4.cd COMMAND:
cd command is used to change the directory.

SYNTAX:
The Syntax is
cd [directory | ~ | ./ | ../ | - ]

5.cp COMMAND:
cp command copy files from one location to another. If the destination is an
existing file, then the file is overwritten; if the destination is an existing directory,
the file is copied into the directory (the directory is not overwritten).

SYNTAX:
The Syntax is
cp [OPTIONS]... SOURCE DEST

6.date COMMAND:
date command prints the date and time.

SYNTAX:
The Syntax is
date [options] [+format] [date]

7.echo COMMAND:
echo command prints the given input string to standard output.

SYNTAX:
The Syntax is
echo [options..] [string]
8.grep COMMAND:
grep command selects and prints the lines from a file which matches a given string or
pattern.

SYNTAX:
The Syntax is
grep [options] pattern [file]

9.hostname COMMAND:
hostname specifies the name of the host.

SYNTAX:
The Syntax is
hostname [-a | -d | -f | -h | -i | -s]

10.head COMMAND:
head command is used to display the first ten lines of a file, and also specifies how
many lines to display.

SYNTAX:
The Syntax is
head [options] filename

11.hostid COMMAND:
hostid command prints the numeric identifier or id of the current host in hexadecimal.

SYNTAX:
The Syntax is
Hostid

12.id COMMAND:
id command prints the effective(current) and real userid(UID)s and groupid(GID)s.

SYNTAX:
The Syntax is
id [options]

13.kill COMMAND:
kill command is used to kill the background process.

SYNTAX:
The Syntax is
kill [-s] [-l] %pid

14.last COMMAND:
last command is used to display the last logged in users list. Last logged in users
informations are read from the file /var/log/wtmp.

SYNTAX:
The Syntax is
last [options]

15.ls COMMAND:
ls command lists the files and directories under current working directory.

SYNTAX:
The Syntax is
ls [OPTIONS]... [FILE]

16.man COMMAND:
man command which is short for manual, provides in depth information about the
requested command (or) allows users to search for commands related to a particular
keyword.

SYNTAX:
The Syntax is
man commandname [options]


17.mkdir COMMAND:
mkdir command is used to create one or more directories.

SYNTAX:
The Syntax is
mkdir [options] directories

18.mv COMMAND:
mv command which is short for move. It is used to move/rename file from one directory to
another. mv command is different from cp command as it completely removes the file from the
source and moves to the directory specified, where cp command just copies the content from
one file to another.

SYNTAX:
The Syntax is
mv [-f] [-i] oldname newname

19.passwd COMMAND:
passwd command is used to change your password.

SYNTAX:
The Syntax is
passwd [options]


20.pwd COMMAND:
pwd - Print Working Directory. pwd command prints the full filename of the current working
directory.

SYNTAX:
The Syntax is
pwd [options]

21.rm COMMAND:
rm linux command is used to remove/delete the file from the directory.

SYNTAX:
The Syntax is
rm [options..] [file | directory]

22.rmdir COMMAND:
rmdir command is used to delete/remove a directory and its subdirectories.

SYNTAX:
The Syntax is
rmdir [options..] Directory
23.sort COMMAND:
sort command is used to sort the lines in a text file.

SYNTAX:
The Syntax is
sort [options] filename

24.Shutdown COMMAND:
Shutdown - Turn off the computer immediately or at a specified time.

SYNTAX:
The Syntax is
/sbin/shutdown [-t sec] [-arkhncfFHP] time [warning-message]

25.tail COMMAND:
tail command is used to display the last or bottom part of the file. By default it
displays last 10 lines of a file.

SYNTAX:
The Syntax is
tail [options] filename

26.useradd COMMAND:
useradd - Adds new user to the linux system, with specified user-name. When a new user is
added then a corresponding entry is made in files /etc/passwd, /etc/group and /etc/shadow

SYNTAX:
The Syntax is
useradd [options] [username]

27.who COMMAND:
who command can list the names of users currently logged in, their terminal, the time they
have been logged in, and the name of the host from which they have logged in.

SYNTAX:
The Syntax is
who [options] [file]

28.whois COMMAND:
whois command lists the information about the domain owner of the given domain.

SYNTAX:
The Syntax is
whois [option] query

29.alias COMMAND:
alias command allows you to create a shortcut to a command. As the name indicates, you can
set alias/shortcut name for the commands/paths which is too longer to remember.

SYNTAX:
The Syntax is
alias [options] [ AliasName [ =String ] ]

30.file COMMAND:
file command tells you if the object you are looking at is a file or a directory.

SYNTAX:
The Syntax is
file [options] directoryname/filename

31.find COMMAND:
find command finds one or more files assuming that you know their approximate filenames.

SYNTAX:
The Syntax is
find path [options]
.
32.free COMMAND:
free command displays information about free and used memory on the system.

SYNTAX:
The Syntax is
free [options] [-V]

33.finger COMMAND:
finger command displays the user's login name, real name, terminal name and write status (as
a ''*'' after the terminal name if write permission is denied), idle time, login time, office location
and office phone number..

SYNTAX:
The Syntax is
finger [-lmsp] [user ...] [user@host ...]

34.fgrep COMMAND:
fgrep command is used to search one or more files for lines that match the given string or
word. fgrep is faster than grep search, but less flexible: it can only find fixed text, not regular
expressions.

SYNTAX:
The Syntax is
fgrep [options] pattern [file]

35.fg COMMAND:
fg command is used to place a job in foreground.

SYNTAX:
The Syntax is
fg [specify job]

36.fdisk COMMAND:
fdisk command is used for partition table manipulator. Hard disks can be divided into
one or more logical disks called partitions.

SYNTAX:
The Syntax is
fdisk [options]

37.lastlog COMMAND:
lastlog command is used to print the last login times for system accounts. Login
information is read from the file /var/log/lastlog.

SYNTAX:
The Syntax is
lastlog [options]

38.less COMMAND:
less command is used to display text in the terminal screen. It just prints the text in the
given file, you cannot edit or manipulate the text here. To display the file from the
specified line, enter the line number followed by colon(:). It allows Forward and
backward movement in the file.

SYNTAX:
The Syntax is
less [options] filename

39.link COMMAND:
link command is used to create a link to a file. It is also called as hard link. Inode will be
same for source and destination.

SYNTAX:
The Syntax is
link existingfilename newfilename (or) link source destination

40.ln COMMAND:
ln command is used to create link to a file (or) directory. It helps to provide soft link for
desired files. Inode will be different for source and destination.

SYNTAX:
The Syntax is
ln [options] existingfile(or directory)name newfile(or directory)name



41.chmod command - change file mode bits

SYNTAX
chmod [OPTION]... MODE[,MODE]...
FILE...

42. cmp command - compare two files byte by byte

SYNTAX
cmp [OPTION]... FILE1 [FILE2 [SKIP1
[SKIP2]]]

43. cmp command - compare two files byte by byte

SYNTAX
cmp [OPTION]... FILE1 [FILE2 [SKIP1
[SKIP2]]]

44. write command send a message to another user

SYNTAX
write user [ttyname]








45.ssh command OpenSSH SSH client (remote login program)

SYNTAX
ssh [-1246AaCfgKkMNnqsTtVvXxY]

46.whoami command - print effective userid

SYNTAX
whoami [OPTION]...

47. lpr command - print files

SYNTAX
lpr [ -E ] [ -H server[:port] ] [ -U
username ] [ -P destination[/instance]
] [ -# num-copies [ -h ] [ -l ] [ -m ]
[ -o option[=value] ] [ -p] [ -q ] [ -r
] [ -C/J/T title ] [ file(s) ]



48. vim command - Vi IMproved, a programmers text
editor

SYNTAX
vim [options] [file ..]

49. THE ping COMMAND
ping, ping6 - send ICMP ECHO_REQUEST to
network hosts

50.THE wall COMMAND

wall write a message to users

SYNTAX
wall [file]

You might also like