You are on page 1of 19

Terminal

Most operating systems have two types of interfaces

Graphical User Interface (GUI)


Command Line Interface (CLI)

Terminal is the Linux's shell (Command Line ) interface.


The default shell prompt for a user is : $ The default prompt for root user is : #

How to get Terminal


Applications --> System Tools --> Terminal

clear man name passwd

clear - Clear the terminal screen


man - Formats and displays the on-line manual pages

name name of the command

Passwd Update user's password

E.g.

$ clear
$ man clear $ passwd

cal [-smjy13] [[[day] month] year]

Cal displays a simple calendar. If arguments are not specified, the current month is displayed.
Options

-1 Display single month output. (This is the default.)


-3 Display previous/current/next month output. -s Display Sunday as the first day of the week. (This is the default.) -m Display Monday as the first day of the week. -j Display Julian dates (days one-based, numbered from January 1). E.g. $ cal $ cal -m -3 -y Display a calendar for the current year.

$ cal 16 9 10

1. date [OPTION]... [+FORMAT] 2. date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

1. Display the current time in the given FORMAT


2. Set the system date. Options --date=STRING display time described by STRING, not now --set=STRING set time described by STRING

E.g.

$ date d=11:30:45 # date --s=11:30:45

# date 0920214010.34

echo [OPTION]... [STRING]...

Echo the STRING(s) to standard output.


OPTION
-n -e -E do not output the trailing newline enable interpretation of backslash escapes disable interpretation of backslash escapes(default)

E.g. $ echo Hai $ echo Good Morning

FILE SYSTEM STRUCTURE

Series of folders in the root directory Each of these folders contain important system files When a device such as a USB flash drive or CD/DVD drive is mounted, a folder is created for it under media Absolute Pathnames

Absolute pathnames begin with a slash (/) or root directory.

Relative Pathnames

Specifies location relative to current working dirrectory.


Specify one or more characters of a file/directory name

Wildcard characters

* Represents multiple characters ? Represents a single character

FILE SYSTEM STRUCTURE

cd [-L|-P] [dir]

Change the current directory to dir The -P option says to use the physical directory structure The -L option forces symbolic links to be followed

E.g.
$ $ $ $

cd /home/user1 - change to /home/user1 cd s1el cd \ cd / - change to s1el directory - change to the parent directory - change to root directory

ls [OPTION]... [FILE]...

ls List directory

OPTION
-1 List one file per line -X Sort alphabetically -C list entries by columns -i Print the index number of each file -l Long listing format -o Do not list group information -p Append / indicator to directories

E.g.

$ ls -1 -p -X

mkdir [OPTION] DIRECTORY...

mkdir - Make directories

OPTION
-v Print a message -m Mode

E.g.
$ mkdir S1Elx $ mkdir -v Sem1

rmdir [OPTION]... DIRECTORY...

Remove the DIRECTORY(ies), if they are empty

OPTION
-v Output a message -p Remove DIRECTORY and its ancestors.

E.g.
$ rmdir Sem1 $ rmdir -v S1El

cp [OPTION]... SOURCE

DEST

cp - copy files and directories

OPTION
-i Prompt before overwrite -l Link files instead of copying -R, -r Copy directories recursively -v Display a message

E.g.
$ cp -i file1 file2 $ cp -v /home/user1/mydoc /home/user2/doc2

mv [OPTION]... SOURCE DEST

mv - move (rename) files

OPTION
-i Prompt before overwrite -v Display message -f Do not prompt before overwriting

E.g.
$ mv -i -v file1 file2 $ mv -f /home/user1/doc/file1 /home/user1/file2

chown [OPTION]... [OWNER][:[GROUP]] FILE...

chown - change file owner and group

OPTION
-c Report only when a change is made -R Operate on files and directories recursively -f Suppress most error messages -v Output a diagnostic for every file processed

E.g.
$ chown root /u $ chown root:staff /u

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

chmod - change file mode bits

OPTION
-f Suppress most error messages -v Output a diagnostic for every file processed -R Change files and directories recursively

Each MODE is of the form [ugoa]*([+=]([rwxXst]*'

MODE

A combination of the letters ugoa controls which users access to the file will be changed: the user who owns it (u), other users in the files group (g), other users not in the files group (o), or all users (a).
The operator + causes the selected file mode bits to be added to the existing file mode bits of each file; - causes them to be removed; and = causes them to be added The letters rwxXst select file mode bits for the affected users: read (r), write (w), execute (or search for directories) (x), execute/search only if the file is a directory or already has execute permission for some user (X), set user or group ID on execution (s), restricted deletion flag or sticky bit (t).

chmod Example
$ chmod o+r+w+x m.jpeg

$ chmod u+r,g+w,o+w m.jpeg


$ chmod u-r,g-w,o-w m.jpeg $ chmod ugo+rwx m.jpeg

cat [OPTION] [FILE]...

cat - concatenate files and print on the standard output

OPTION
-n Number all output lines -E Display $ at end of each line -b Number nonempty output lines

E.g.
$ cat -n a.txt b.txt $ cat -E -b a.txt

You might also like