Nothing Special   »   [go: up one dir, main page]

Lab 2 OS Commands in Linux

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

1

NAME: LAIBA BABAR


ROLL NO: 2021-BCS-019
COURSE: OPERATING SYSTEM
INSTRUCTOR: SIR ADEEL KHALID

LAB#2
Command: cat
“cat” is short for concatenate. This command is used to create, view and concatenate files.
Example:
o cat file1 file2 > file3
This command combines the contents of the first two files into the third file.

OPERATING SYSTEM laiba qureshi


2

Command: pwd
“pwd” stands for print working directory. It displays your current position in the
UNIX/LINUX file system.
Example:
o pwd It is simply used to report your current working directory.

Command: ls
“ls” stands for list. It is used to list information about files and directories.
Example:
It provides a very basic listing of the files in your current working directory. Filenames
beginning with a decimal are considered hidden files, and they are not shown.

o ls -al
This command provides a long listing of information about all files in the current directory.

OPERATING SYSTEM laiba qureshi


3

This is probably the most used version of the ls command.

Command: mv
The “mv” command is used to move and rename files.
Examples:
o mv Lab OS Lab
This command renames the file “Lab” to the new name “ OSLab”

OPERATING SYSTEM laiba qureshi


4

o mv OSLab garbage
This command renames the file “OSLAB1” to the new name “garbage”.

Command: rm
The “rm” command is used to remove files and directories.
Examples:
o rm OSLab
This command deletes the file named “OSLab”(assuming you have permission to delete this
file).

OPERATING SYSTEM laiba qureshi


5

o rm OSLab1 OSLab2
This command deletes the files named “Chapter1”, “Chapter2”and “Chapter3”.

OPERATING SYSTEM laiba qureshi


6

AFTER COMMAND:

o rm -i OSLab1 OSLab2
This command prompt you before deleting any of the three files specified. The -i option stands
for inquire.
You must answer y (for yes) for each file you really want to delete. This can be a safer way to
delete files.

o rm in*

OPERATING SYSTEM laiba qureshi


7

This command deletes all files in the current directory whose filename begins with the
characters “in”

o rm *.txt
This command deletes all files in the current directory whose filename ends with the
characters “txt”

OPERATING SYSTEM laiba qureshi


8

o rm -r Labs This command deletes the directory named “Labs”. This directory, and all of
erased from the disk, including any sub-directories and files.

Command: cp
The “cp” command is used to copy files and directories. When using the cp command, you
must always specify both the source and destination of the file(s) to be copied.
Examples: o cp /home/Lab1 /home/OSLabs
This command copies the “Lab1” file in “/home” to the directory named “/home/OSLab”

OPERATING SYSTEM laiba qureshi


9

Command: mkdir
The “mkdir” command is used to create new directories (sub-directories).
Examples:
o mkdir Lab
This command creates a new directory named “Lab” in your current directory. (This example
assumes that you have the proper permissions to create a new sub-directory in your current
working directory.)

o mkdir memos letters


This command creates two new sub-directories (memos, letters) in the current directory.

OPERATING SYSTEM laiba qureshi


10

o mkdir /home/labb
This command creates a new directory named “lab” in the directory “/home”

o rm -r labb

OPERATING SYSTEM laiba qureshi


11

This command deletes the directory named “labb” This directory, and all of its' contents,
are erased from the disk, including any sub-directories and files.

Command: cd, chdir


“cd” stands for change directory. It is the primary command for moving around the file
system.
Examples:
o cd /home
This command moves you to the “/home” directory. “/home” becomes your current working
directory.

o cd /h*
Moves you to the “/home” directory - if this is the only directory matching this wildcard
pattern.

OPERATING SYSTEM laiba qureshi


12

o cd
Issuing the “cd” command without any arguments moves you to your home directory.

Command: clear
“Clear” is used to clear the full screen of text, perhaps garbage on the terminal.
Examples:
o clear
This command clears all text on the terminal.

OPERATING SYSTEM laiba qureshi


13

OPERATING SYSTEM laiba qureshi

You might also like