Linux Manual
Linux Manual
LINUX OS Manual
for
Students, faculty and Staff
(Ravi K. Walia)
Assistant Professor & Incharge
Computer & Instrumentation Centre
Dr. Y. S. Parmar University of Horticulture & Forestry,
Nauni Solan INDIA (HP)
1 CIC-UHF
LINUX OS Manual
PREFACE
This document has been prepared for students, faculty, and staff at Dr. Y. S.
Parmar University of Horticulture & Forestry, Nauni, Solan (HP) India.
Linux, based on the Unix is one of most powerful and versatile operating system.
A research team at AT&T’s Bell Labs developed Unix in the late 1960s and early
1970s with a focus on creating an operating system that would be accessible and
secure for multiple users. In 1991, Linus Torvalds released the Linux kernel as
free, open-source software. Open source means that the code is fully visible, and
can be modified and redistributed.
Linux is used in most of the servers like web Server, Email Server, DNS Server,
File Servers, workstations, home user PC, client and even more than 80% of
supercomputers.
Most of Linux version has GUI like MS Windows, however to explore the full
capability of Linux user need to learn the command mode. Each command in
Linux has many options which effect the output. This manual cover main features
of Linux, basic concepts, file system and security access, most of the commands
with example and vi editor. To explore more about command such as attribute and
parameters user can use inbuilt help using man command.
2 CIC-UHF
LINUX OS Manual
Feature of Linux
BASIC CONCEPTS
Kernel: The kernel is the heart of the operating system. It interacts with the hardware
and most of the tasks like memory management, task scheduling and file management.
Shell: The shell is the utility that processes your requests. When you type in a
command at your terminal, the shell interprets the command and calls the program that
you want. The shell uses standard syntax for all commands. C Shell, Bourne Shell and
Korn Shell are the most famous shells.
Commands and Utilities: There are various commands and utilities which you can
make use of in your day to day activities. cp, mv, cat and grep, etc. are few examples
of commands and utilities.
Files and Directories: All the data of Linux is organized into files. All files are then
organized into directories. These directories are further organized into a tree-like
structure called the filesystem. There are three basic types of files –
Ordinary Files − An ordinary file is a file on the system that contains data, text,
3 CIC-UHF
LINUX OS Manual
or program instructions. In this tutorial, you look at working with ordinary files.
Directories − Directories store both special and ordinary files. For users
familiar with Windows or Mac OS, Unix directories are equivalent to folders.
Special Files − Some special files provide access to hardware such as hard
drives, CD-ROM drives, modems, and Ethernet adapters. Other special files
are similar to aliases or shortcuts and enable you to access a single file using
different names.
SYSTEM BOOTUP
If you have a computer which has the Linux operating system installed in it, then you
simply need to turn on the system to make it live.
As soon as you turn on the system, it starts booting up and finally it prompts you to log
into the system, which is an activity to log into the system and use it for your day-to-
day activities.
Login Linux
When you first connect to a Linux system, you usually see a prompt such as the
following:
login:
To log in
• Have your userid (user identification) and password ready. Contact your
system administrator if you don't have these yet.
• Type your userid at the login prompt, then press ENTER. Your userid is case-
sensitive, so be sure you type it exactly as your system administrator has
instructed.
• Type your password at the password prompt, then press ENTER. Your
password is also case-sensitive.
• If you provide the correct userid and password, then you will be allowed to
4 CIC-UHF
LINUX OS Manual
enter into the system. Read the information and messages that comes up on
the screen, which is as follows.
You will be provided with a command prompt (sometime called the $ prompt or %
prompt) where you type all your commands.
5 CIC-UHF
LINUX OS Manual
6 CIC-UHF
LINUX OS Manual
$cp abc /xyz Make copy of file abc in the directory xyz with
name abc (if directory xyz exist) else make
copy of file abc with name xyz in the root
directory (/).
7 CIC-UHF
LINUX OS Manual
8 CIC-UHF
LINUX OS Manual
$ head myfile The head command writes the first ten lines
of a file to the screen.
$ head -12 myfile Display all line starting from line 12 on the
screen
$ tail myfile The tail command writes the last ten lines of a
file to the screen.
$cat xyz >>newfile Append the content of file xyz at the end of
newfile
$ sort < abc Sort the file abc and display the content of
screen
10 CIC-UHF
LINUX OS Manual
11 CIC-UHF
LINUX OS Manual
12 CIC-UHF
LINUX OS Manual
13 CIC-UHF
LINUX OS Manual
Linux use the inverted tree type structure (like windows) for directories as shown below
Following are the directories that exist on the major versions of linux –
Directory Description
/ This is the root directory which should contain only the directories
needed at the top level of the file structure
/bin This is where the executable files are located. These files are
available to all users
/lib Contains shared library files and sometimes other kernel-related files
14 CIC-UHF
LINUX OS Manual
/home Contains the home directory for users and other accounts
/mnt Used to mount other temporary file systems, such as cdrom and
floppy for the CD-ROM drive and floppy diskette drive, respectively
/usr Used for miscellaneous purposes, and can be used by many users.
Includes administrative commands, shared files, library files, and
others
/var Typically contains variable-length files such as log and print files and
any other type of file that may contain a variable amount of data
$ ls -l
You will see that you now get lots of details about the contents of your directory,
similar to the example below.
15 CIC-UHF
LINUX OS Manual
Column 1: Represents the file type and the permission given on the file Every file
line begins with a d, -, or l. These characters indicate the type of the file that's listed.
Prefix Description
- Regular file, such as an ASCII text file, binary executable, or hard link
b Block special file. Block input/output device file such as a physical hard
drive
The 9 remaining symbols indicate the permissions, or access rights, and are taken
as three groups of 3.
The left group of 3 gives the file permissions for the user that owns the file (or
directory) (coh in the above example);
the middle group gives the permissions for the group of people to whom the
file (or directory) belongs (uhf in the above example);
the rightmost group gives the permissions for all others.
The symbols r, w, etc., have slightly different meanings depending on whether they
refer to a simple file or to a directory.
r (or -), indicates read permission (or otherwise), that is, the presence or
absence of permission to read and copy the file
w (or -), indicates write permission (or otherwise), that is, the permission (or
otherwise) to change a file x (or -), indicates execution permission (or
16 CIC-UHF
LINUX OS Manual
Column 2: Represents the number of memory blocks taken by the file or directory.
Column 3: Represents the owner of the file. This is the Linux user who created this
file.
Column 4: Represents the group of the owner. Every Linux user will have an
associated group.
Column 6: Represents the date and the time when this file was created or modified
for the last time.
Only the owner of a file can use chmod to change the permissions of a file.
The options of chmod are as follows
u : user g : group o : other a : all
r : read w : write /delete x : execute/ accessdirectory
+ : add permission - : take away permission
17 CIC-UHF
LINUX OS Manual
For example, to remove read write and execute permissions on the file myfile for
the group and others, type
Grep Command
Grep is one of many standard linux utilities. It searches files for specified words or
patterns.
$ grep “string1$” filename List the lines containing string1 in the end
$ grep –v “string1” filename List the lines not containing string1 in file
$ find . –name “*.mp3” | grep –i JayZ | Find all mp3 file then find file from JayZ
grep –vi “remix” then remove remix file from the list
18 CIC-UHF
LINUX OS Manual
vi editor commands
Use the vi editor to create ordinary files on any linux system. You simply need to give
the following command
$vi abc
The above command will open a file with the given filename. Now, press the key i to
come into the edit mode. Once you are in the edit mode, you can start writing your
content in thefile.
Press the key esc to come out of the edit mode. Press two keys Shift + ZZ together to
come out of the file completely
Ctrl-G Display line number of cursor C Change from current position to end
of line
nG Move cursor to line number n
dd Delete current line
:n Move cursor to line number n
ndd Delete n lines
G Move to last line in file
D Delete remainder of line
dw Delete word
File Handling
J Join two lines
:w Write file
19 CIC-UHF
LINUX OS Manual
20 CIC-UHF