Title: LINUX Basics
1LINUX Basics
2LOGIN and LOGOUT
This is how a Linux login screen looks like.
There will be a login prompt where the user will
be asked to enter his Account or User Name.
For security purposes, each account will have a
password which is asked by the operating system
every time a user wants a login. As the user
enter the password, the characters typed will not
be printed on the screen.
3LOGIN and LOGOUT
- If a user has a valid account name
and the correct password is entered, Linux will
display its prompt (usually the dollar sign, )
to indicate that it is ready to receive
commands/instructions. -
- A user may opt to change his password.
This may be achieved by typing passwd at the
prompt. - passwd
- Changing password for harriet
- harriets Old password
- harriets New password
- Enter the new password again
- It is advised that users change their
password from time to time. Also note that Linux
is case sensitive. An upper case letter is
different from the lower case. - To quit a session, a use logs-out by
pressing ltCTRLgt - ltDgt or typing either exit or
logout -
4LINUX COMMAND FORMAT
- Most Linux commands have the following format
-
- Command_name optionarguments
- A user types in the name of the command to
be executed followed by the options (option are
generally preceded by a dash or minus sign) and
then followed by the arguments. Options
determine how the command will be executed while
arguments are the data to be processed by the
command. - Note
- Some commands do not require the use of options
and/or arguments. Examples of such are the
passwd and clear commands.
5Command Usage and Principle
- Separation - each component of Linux command
should be separated a space. - Example
- ls -l test.txt
- Order - The position of the components of an
Linux command should not be interchanged. The
order should always be - Example
- ls -l test.txt
- Multiple Option - The rule of separation can be
applied in case of multiple options. An option
should be preceded by a space. - Example
- ls -l -C -d sample.doc
6Basic Commands
- Commands are entered either by typing the name
of the commands at the Linux prompt. The command
is executed by pressing the ltentergt or ltreturngt
key. - The date command is used if the user wants to
know the current date and time. Only the system
administrator can change the system date and
time. - Example date
- Mon Oct 6 192450 PST 1996
- Typing clear at the prompt followed by the
ltentergt or ltreturngt key will simply clear the
screen. This is similar to cls command in DOS.
7Basic Commands
- Typing who command is used to determine the
users currently logged in the system. The output
will give the user name together with the TTY or
terminal number (the exact terminal being used) - Example who
- root tty4
- user3 tty9
- user1 tty2
- Typing whoami command is used to determine the
users currently logged-in at a particular
terminal. For example if someone happens to see
a terminal left on with someone logged in, typing
whoami at the prompt will give the name of the
user currently logged-in. - Example whoami
- user
8Basic Commands
- The finger command displays information about
the users currently logged on to the system. - Example
- finger harriet
- Login name harriet
- Directory /home/harriet Shell /bin/bash
- Last login Thu 22 052610 (PHT) on 0
- This cal command gives the user the calendar for
the current month and year. The cal year command
will give the user the whole calendar for the
year specified. Same with the cal month year
command, it will give the calendar for the
specific month and year. - The bc command will enable user to access binary
calculator.
9Sample
- ls command
- The ls (list) command list the name of files in
a given directory. Typing ls without any option
and argument at the prompt (followed by an
ltentergt key) gives the user a listing of the
files in columns and in alphabetical order. - Example
- ls
- shapes quiz1.doc mike.let
- test tymi.doc sample1
10Command Usage and Principle
- Multiple Arguments - The rule of separation
should also be applied in case of multiple
options. Each argument is listed but separated
from each other with a space. - Example
- ls -l sample doc.txt test
- Multiple Commands - Several commands maybe
entered at a single Linux prompt. In such cases,
each command unit is delimited by a semi-colon
(). The commands will then be executed
consecutively. - Example
- ls ls -a
11Command and Option
- The l option gives a long listing of the files.
It consists of 8 columns - First Security Access Modes
- Second Number of Links
- Third Owner of this file and directory
- Fourth Group where owners belong
- Fifth Size of Files
- Sixth Date the file was last modified
- Seventh Time the file was last modified
- Eight Name of the File or Directory
- Example
- ls -l
- -r-xr-xr-x-l user1 staff 42 Jan 13 1100
harriet.txt
12Command and Option
- The a option gives a listing of the files
including hidden files (those which starts with a
.) - Example
- ls -a
- profile.sh_history quiz.doc
- Command and Argument
- Example
- ls sample
- arithmetic
- Command,Option and Argument
- Example
- ls -l sample.c
- -rw -r--r--2 tymi staff July 29 1130 sample.c
13Common Usage and Principle
- Wild Cards
- Asterisk () - The asterisk wild card will
match any number of characters that occur at the
designated position in the pattern. - Example
- ls ch
- chapter5 champ charie_text
- ls er
- october system.ver
- Note
- In DOS . represents all files (any name and
extension). This is not applicable in Linux
since it does not follow the concept of file
extension. Instead . will be interpreted as
any file with a period in its filename. To
represent all files in Linux, just simply type .
14Wildcards
- Question Mark (?) - Like in DOS, the question
mark will match any single character - Example
- ls ?ark
- mark lark 5ark
- Square Brackets - The square brackets are
similar to the question mark in the sense that it
will match any single character. However,
options may be specified if the square brackets
are used. Reverse listings can also be done by
using - Example
- ls letter246.doc
- letter2.doc letter4.doc letter6.doc
-
- ls memo_a-c.doc
- memo_a.dco memo_b.doc memo_c.doc
15Linux Documentation
16Manual Pages
- Manual Pages
- Commands and system calls
- Viewed a page at a time
- Search for keywords
- man Command
- man command
- Output section of manual for commands,
subroutine, and files. - Manual information consists of
- PURPOSE (one-line description)
- SYNTAX (command syntax)
- DESCRIPTION
- FILES (associated files)
- RELATED INFORMATION
- BUGS (odd behavior)
17Linux Files and Directories
18File
- File
- A collection of data
- A stream of characters
- No structure is imposed by the operating
system - - the user is free to structure and interpret the
contents of a file in whatever way it is
appropriate.
19File Types
- File Types
- Ordinary
- Text or code data
- No particular internal format
- Directory
- A table of contents
- Special Files
- Represents hardware or logical devices
- Found in directory /dev
20Directory
- Directory
- Unique type of file that contains only the
information needed to access files or other
directories. - Each directory contains a file or subdirectory
name and its associated inode number - The pwd command can be used to find out what
your current directory is
21Linux Filenames
- Should be descriptive of the contents
- Should only use alphanumeric characters,
UPPERCASE, lowercase, number, , _at_, _ - Should not be the same as a system command
- Are case sensitive
- Starting with a . are hidden from the normal ls
commands - The maximum number of characters for a filename
is 255
22Linux File Types
- The / (root) directory contains many directories
that are critical in the operations of the system - The /usr directory contains system programs and
installed licensed program packages - The /home directory contains user login
directories and files - The /var directory contains files and logs that
dynamically change - The /tmp directory will hold files that are
temporarily needed or created by applications and
programs.
23Hierarchical Structure
24Pathnames
- Pathnames
- A sequence of filenames, separated by slashes
(/), that describes the path, or route, the
system must follow to locate a file in the file
system. - Two types
- Absolute - start from / (the root directory)
- Relative - start from the current working
directory - Examples
- /home/tymi/.sh_history (Absolute)
- doc/sample (relative)
- ./harriet/quiz1 (relative)