Sei sulla pagina 1di 10

ARAB AMERICAN UNIVERSITY – FACULTY OF ENGINEERING & INFORMATION TECHNOLOGY – COMPUTER

SYSTEM ENGINEERING - Linux Lab


EXPERIMENTE #4 Basic Command line 1

Pre Laboratory:
1. What are the three types of users in Linux?
2. What is the benefit of /home directory?
3. What are the differences between files and directory?
4. What is the difference between terminals on TTY CONSOL ports?
5. What is the difference between cp and mv command?

Objective:
 Learn about the types of users in Unix/Linux system.
 Differentiate between root directory and home directory.
 Learn some basic commands in Unix/Linux including help, list and history commands
 Learn how to deal with directories and files in Linux.
 Learn how to kill and pause processes.

Introduction:
Users in Linux:
The root user account – full permission user:
This is the main user account in Linux system. It is automatically created during the installation. It
has the highest privilege in system. It can do any administrative work and can access any service.
This account is intended for system administration and should be used only for this purpose. It
should not be used for routine activities. It can’t be deleted. But if require, it can be disabled.
The regular user account – limited user:
This is the normal user account. During the installation, one regular user account is created
automatically. After the installation, we can create as many regular user accounts as we need. This
account has moderate privilege. This account is intended for routine works. It can perform only
the tasks for which it is allowed and can access only those files and services for which it is
authorized. As per requirement, it can be disabled or deleted.
The service account:
Service accounts are created by installation packages when they are installed. These accounts are
used by services to run processes and execute functions. These accounts are neither intended nor
should be used for routine work.

Mr. Allam Abumwais Eng. Nour Kmail


ARAB AMERICAN UNIVERSITY – FACULTY OF ENGINEERING & INFORMATION TECHNOLOGY – COMPUTER
SYSTEM ENGINEERING - Linux Lab
EXPERIMENTE #3 Basic Unix/Linux commands

Linux Home Directory


The Linux home directory is a directory for a particular user of the system and consists of
individual files. It is also referred to as the login directory. This is the first place that occurs after
logging into a Linux system. It is automatically created as "/home" for each user in the directory'.
It is a standard subdirectory of the root directory. The root directory contains all other directories,
subdirectories, and files on the system. It is denoted by a forward slash (/).

The home directory can be said as a personal working space for all the users except root. There is
a separate directory for every user. For example, two users 'jtp1' and 'jtp2' will have directories
like "/home/jtp1" and "/home/jtp2". These users will have all the rights under their directory files.

The root (administrative) user is the only user who has its home directory in a different location
by default. The path of the root user is '/root/', where it has control under all the directories and
files.

 ~ : /home/username

2
ARAB AMERICAN UNIVERSITY – FACULTY OF ENGINEERING & INFORMATION TECHNOLOGY – COMPUTER
SYSTEM ENGINEERING - Linux Lab
EXPERIMENTE #3 Basic Unix/Linux commands

Difference between Root and Home Directory:

Root Directory Home Directory


The root directory is the topmost level of the The home directory is a subdirectory of the
system drive. root directory.
It is denoted by a slash '/'. It is denoted by '~' and has path
"/users/username".
The admin has access to make any changes in No user other than the root user can change the
the files and settings. settings of the entire system.
The admin can create a user. Any user having a home directory cannot
create a user.
In the Linux file system, everything comes The home directory contains a particular user's
under the root directory. data.

Move between Users:


You can navigate between users using su (switch user) command.

3
ARAB AMERICAN UNIVERSITY – FACULTY OF ENGINEERING & INFORMATION TECHNOLOGY – COMPUTER
SYSTEM ENGINEERING - Linux Lab
EXPERIMENTE #3 Basic Unix/Linux commands

Print Working directory:


pwd command is used to write the full pathname of the current working directory.

Man command:
Man command in Linux is used to display the user manual of any command that we can run on
the terminal. It provides a detailed view of the command which includes NAME, SYNOPSIS,
DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, ERRORS, FILES,
VERSIONS, EXAMPLES, AUTHORS and SEE ALSO.

--help command:
--help command is used to get the complete usage of that command.

4
ARAB AMERICAN UNIVERSITY – FACULTY OF ENGINEERING & INFORMATION TECHNOLOGY – COMPUTER
SYSTEM ENGINEERING - Linux Lab
EXPERIMENTE #3 Basic Unix/Linux commands

whatis command:
whatis command in Linux is used to get a one-line manual page descriptions.

clear command:
clear command is used to clear the screen.

Directories and Files:


The directory is a multi-hierarchy file which contains subdirectories and many files that differ in
the type of data they contain. The file contains only one type of data.
Programs, services, texts, images, and so forth, are all files. Input and output devices, and
generally all devices, are considered to be files, according to the Linux system.

Directories and Files Commands:

5
ARAB AMERICAN UNIVERSITY – FACULTY OF ENGINEERING & INFORMATION TECHNOLOGY – COMPUTER
SYSTEM ENGINEERING - Linux Lab
EXPERIMENTE #3 Basic Unix/Linux commands

 cd (Change Directory) command: used to change the current working directory.

Syntax cd [directory].

cd ~ : put the user in their home directory.


cd .. : move the user up one directory. So, if they are /usr/bin/tmp , cd .. moves them
to /usr/bin
cd dir: put the user in a subdirectory ;for example, if they are in /usr , typing cd bin will put
them in /usr/bin , while cd /bin puts them in /bin .

 Create directories or files:

1. touch command :

Syntax touch [file_name].

It is used to create a file without any content. The file created using touch command
is empty. This command can be used when the user doesn’t have data to store at the
time of file creation.

Syntax touch file1 file2 file3 .. , to create multiple files

2. mkdir command:

Syntax mkdir [options] [directories].

It allows users to create or make new directories. mkdir stands for “make directory.”

 Remove directories or files :

Syntax rm [option] [file|dir].

1. rm command : To delete a single file.


.

2. rmdir command: to remove an empty directory.

3. rm –r command: To remove a directory and all its contents, including any


subdirectories and files, use the rm command with the recursive option, -r.

6
ARAB AMERICAN UNIVERSITY – FACULTY OF ENGINEERING & INFORMATION TECHNOLOGY – COMPUTER
SYSTEM ENGINEERING - Linux Lab
EXPERIMENTE #3 Basic Unix/Linux commands

4. rm –rf command: To remove non-empty directories and all the files without being
prompted, use rm with the -r (recursive) and -f options.

 Copy and move files or directories:

1. cp command : To make a copy of a file.


Syntax cp <source> <destination>.
cp -r : To copy a directory along with its sub directories.

2. mv command: To move a file from one folder to another.


Syntax mv <source> <destination>.

Example:

Desktop

mydir dir2 f1

F2 F3

History commands:
 history command: shows a list of the commands entered since you started the session.

7
ARAB AMERICAN UNIVERSITY – FACULTY OF ENGINEERING & INFORMATION TECHNOLOGY – COMPUTER
SYSTEM ENGINEERING - Linux Lab
EXPERIMENTE #3 Basic Unix/Linux commands

 last command: displays the list of all the users logged in and out since the
file /var/log/wtmp was created.

 w command: shows who is logged on and what they are doing. This command shows
the information about the users currently on the machine and their processes.

 who command: displays the users currently logged in to your UNIX or Linux operating
system.

 whoami command: displays the username of the current user when this command is
invoked.

 id command: used to find out user and group names and numeric ID's (UID or group ID)
of the current user or any other user in the server.

8
ARAB AMERICAN UNIVERSITY – FACULTY OF ENGINEERING & INFORMATION TECHNOLOGY – COMPUTER
SYSTEM ENGINEERING - Linux Lab
EXPERIMENTE #3 Basic Unix/Linux commands

List commands:
ls lists the files in the current working directory.

Syntax ls [options] [file|dir].

Option Description

ls List all files and directories.

ls -a or ll -a list all files including hidden file starting with '.'

ls -l or ll list with long format - show permissions

ls -la list long format including hidden files

ls -ls list with long format with file size

ls -r list in reverse order

ls -R list recursively directory tree

ls -s list file size

ls -S sort by file size

ls -t sort by time & date

ls -X sort by extension name

ls -lh List all files and directories with another column representing the
size of each file/directory

 Try man ls to display a manual with all possible options for the ls command.

9
ARAB AMERICAN UNIVERSITY – FACULTY OF ENGINEERING & INFORMATION TECHNOLOGY – COMPUTER
SYSTEM ENGINEERING - Linux Lab
EXPERIMENTE #3 Basic Unix/Linux commands

Kill and pause processes:


Ctrl + c: the current running command or process get Interrupt/kill (SIGINT) signal. This signal
means just terminate the process.
Ctrl + d: to close the bash shell or open files when using cat command.
Ctrl + z: suspend the current foreground process running in bash shell.

10

Potrebbero piacerti anche