Lab Task
Lab Task
Lab Task
Objectives
• To Familiarize with the Linux command line interpreter
• To be able to execute and interpret Linux basic commands
Pre-Lab Theory:
There are 2 ways to use the command
1. Absolute mode
2. Symbolic mode
Absolute(Numeric) Mode in
Linux
In this mode, file permissions are not represented as characters but a three-digit
octal umber.
The table below gives numbers for all permissions types.
a. $ls
b. $ls -l
2
Task: Explain all the columns in the output Also interpret the first character of the first
column values Possible characters (-, d, l, p, s, b, c)
3
c. Metacharacters/wild card
i. $ls ch*.doc
Task: First execute ls and then list some files through wild card and write output
3. Change Directory:
$cd ../
Change the directory to one level up
Task: execute ‘pwd’ first then ‘cd ../’ and write the output
Task: First execute ls and then list some files through wild card and write output
4
4. Creating Subdirectories:
$mkdir <subdirectory path>
Task: write the command to create subdirectory Lab1 in pwd
Task: write the command to create directories with the following hierarchy
/Linux_Commands/Lab_Tasks
5. Removing Subdirectories
$rmdir
Task: write the command to create a subdirectory Temp in the current directory and
then write the command to remove it
c. Copy Files
5
$cp <source file path> <destination file path>
Task: create and edit a file temp.dat using gedit with some text and save the
file in the Lab1 directory.
Write the command to copy temp.dat to subdirectory Lab_Tasks created in the
previous task
6
9. Changing the permissions of the file
$chmod <nnn> <filename>
$chmod 777 xyz.txt
Task1: execute ls and write the permissions
Task2: write the command chmod 640 xyz.txt using symbolic mode
Behavior:
7
The command $ls -l lists detailed information about files and directories
in the current directory, including permissions, owner, group, and more.
Using > xyz.dat redirects this information to a file called xyz.dat instead
of displaying it on the screen.
Task2: Append some contents in the existing file ‘xyz.dat’ Write the
command string used to achieve the above task
Columns:
PID (Process ID): This column shows the unique identification number assigned to
each running process. It's a way to uniquely identify and reference processes.
USER: Displays the username of the user who started the process. Each process is
associated with a user.
PR (Priority): Indicates the priority of the process. Lower values generally indicate
higher priority. However, this column is not always used or accurate on all systems.
SHR (Shared Memory): Indicates the amount of shared memory used by the
process. Shared memory is memory that can be used by multiple processes
simultaneously.
S (Status): Shows the current status of the process. Common statuses include:
R: Running
S: Sleeping
D: Disk sleep
Z: Zombie (terminated but not reaped by its parent process)
T: Stopped
%CPU (CPU Usage): Displays the percentage of CPU time used by the process
since the last screen refresh. This column helps identify CPU-intensive processes.
%MEM (Memory Usage): Shows the percentage of physical RAM used by the
process. It's a measure of how much memory the process is consuming.
TIME+ (Total CPU Time): Represents the total accumulated CPU time used by the
process since it started. It's an indicator of how much CPU resources the process has
consumed.
COMMAND: This column displays the name of the command or program associated
with the process
The ps command provides a list of currently running processes, showing their unique Process IDs
(PID), associated terminal type (TTY), CPU time usage, and the associated command or program
(CMD). It's a quick way to see what processes are running on a Unix-like system.
Importance of &:
Running a command with & makes it run in the background, freeing up your terminal for
other tasks. This is essential for multitasking, allowing you to work on other tasks while
9
one runs. It's particularly useful for long-running processes and when working on remote
servers.
1
0
1
1