0% found this document useful (0 votes)
15 views22 pages

OSLABJATIN

The document provides a comprehensive guide to various Linux commands, including their functions and options. Key commands covered include 'pwd', 'mkdir', 'cd', 'rm', 'echo', 'ls', and many others, detailing their usage for file and directory management, system monitoring, and text manipulation. Additionally, it includes basic commands for the 'vi' text editor, outlining how to navigate, edit, and save files.

Uploaded by

princeji98136
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views22 pages

OSLABJATIN

The document provides a comprehensive guide to various Linux commands, including their functions and options. Key commands covered include 'pwd', 'mkdir', 'cd', 'rm', 'echo', 'ls', and many others, detailing their usage for file and directory management, system monitoring, and text manipulation. Additionally, it includes basic commands for the 'vi' text editor, outlining how to navigate, edit, and save files.

Uploaded by

princeji98136
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Operating System Lab File

1. pwd:-
 It will print the current folder path.

2. mkdir :-
 you can create folder using mkdir command.

 you can create multiple folders with one command


 you can also create nested folder using -p option in mkdir command
 This command can also be used to create a hidden folder just add . in
starting

3. dir :-
 dir command in Linux is used to list the contents of a directoryFor
detailed information about each file, use the -l option
4. cd :-
 This command is used to change directory
 To exit from any directory use .. ahead of this command

5. rm :-
 This command is used to remove item
 rm -rf directory_name Forcefully delete all commands without confirmation

rmdir :-
 This command is used to delete a blank directory
 This command is used to remove multiple directories at once

6. echo :-
 This command is used to directly print a message
 This command can also be used to create a empty file
 This command can also be used to create a file with text in it.
7. touch :-
 This command is used to create new file
 If the file already exists this command will update the timestamp of the
file
 touch command can also be used to create a hidden file just start the
name with .
 -m option is used to update only the modification time of a file
8. stat :-
 This command is used to get statistical data of a file
9. cat :-
 This command is used to insert text in any file and then print the content
of file

 cat command can also be used to show contents of multiple files.


 cat command can also be used to concatenate two files in a another file
 If we use -n option with command then we can get number of lines in a file

10. ls :-
 This command is used to list directory contents.
 THE ONE in BLUE is directory and other are files
 -l option is used to list with detailed information
 a option is used to view all hidden files that one starting with .

11. sort :-
 It is used to sort lines of a file numerically, alphabetically or in reverse
order.
 To sort in reverse order use -r option
 To sort numerically use -n option
 -u option removes duplicated while sorting
12. mv :-
 This command can be used to Move files/directories from one location to
another
 This command can also be used to rename a file
13. cp :-
 This command is used to copy file
 This command can also be used to create a new file and copy the data to
that file

14. head :-
 This command can be used to print the starting 10 lines(default) of a file
 By using -n option we can print first n lines
 We can also see the first few lines of multiple files

15. tail :-
 This command can be used to print last 10 lines(default ) of a file
 By using tail -n option you can print last n number of lines
16. find :-
 This command is used to search for files and directories within a directory.
17. tree :-
 The tree command shows a visual hierarchical structure of directories and
files.
 To install use command sudo apt install tree

 tree -s is used to print sizes

 tree -a is used to print hidden files in tree

 tree -d is used to print directories only

18. df :-
 The df command is used to display disk space usage of file systems.
 df -h is used to show specific file system
 df -T is used to Include file system type

19. top :-
 The top command is used to monitor system performance in real-time
 It shows CPU usage, memory usage running processes.

20. chown :-
 Chown command in linux is used to change the ownership of files and
directories.
 We can also use chown command to change only the group
 We can also change both ownership and group at same time
21. history :-
 The history command in Linux of used to view a list of previously executed
commands
22. man :-
 This command is used to get manual of any command q
23. whereis :-
 It is used to locate the binary,source and manual page files for a
command

24. ps :-
 The ps command in is used to display information about running
processes
 ps -e will show all ongoing processes
 ps -aux command is used to get detailed view of all processes
 ps -u username command is used to see the process if a specific user
25. free :-
 Free command is used to display the amount of free and used memory
 This command is used to show values in human- readable format

26. kill :-
 The kill command is used to terminate a running process using its
Process ID.
27. clear :-
 This command is used to clear the terminal screen
28. sudo :-
 sudo command is used to install a package
 create new user using
 sudo command i=can also be used to delete a user

29. lsof :-
 lsof command is used to see which files are currently open
 lsof -u username shoes files opened by a specific user
30. hostname:-
 This command is used to display or set system’s hostname

31. tar:-
 This command is used to create, extract and manipulate archive files
32. zip :-
 It is used to compress files and directories into .zip format

zip -r recursively zips a files directory

c. unzip command

33. grep:-
 It is used to search patterns or text in files
 grep -i ignores the case sensitivity
 grep -n : shows the line numbers
34. sed:-
 It is used to replace , insert or delete text in files

‘1’ is replaced with 4 at every location

35. gpasswd:-
it used for administer.
etc/passwd used to show user.
gpasswd -a is used for add user .
gpasswd -d are used for remove to user.

36. chmod:-
chmod are used for change permission to all file.

Chmod 755 Uses numbers to represent permissions.


37. Id:-
It is ude to show user id group_id.
BASIC VI COMMANDS
To Start vi
Command Description
vi filename Create or edit file starting at line 1
vi -r filename Recover file after system crash

To Exit vi
Command Description
:x Save and quit
:wq Save and quit
:q Quit without saving (if no changes)
:q! Force quit without saving

Moving the Cursor


Command Description
j, <Return> Move cursor down one line
k Move cursor up one line
h, <Backspace> Move cursor left
l, <Space> Move cursor right
0 Move to start of current line
$ Move to end of current line
w Move to beginning of next word
b Move back to beginning of previous
word
:0 or 1G Move to first line in file
:n or nG Move to line n
:$ or G Move to last line in file

Screen Manipulation
Command Description
^f Move forward one screen
^b Move backward one screen
^d Move down (forward) half screen
^u Move up (backward) half screen
^l Redraw the screen
^r Redraw screen, removing deleted
lines
Adding, Changing, Deleting Text
Command Description
u Undo last change (toggle)

Inserting or Adding Text


Command Description
i Insert before cursor, until <Esc>
I Insert at beginning of line, until
<Esc>
a Append after cursor, until <Esc>
A Append at end of line, until <Esc>
o Open new line below current line,
until <Esc>
O Open new line above current line,
until <Esc>

Changing the Text


Command Description
r Replace one character
R Replace characters continuously
until <Esc>
cw Change current word
cNw Change next N words
c Change current line from cursor
cc Change entire line
Ncc / cNc Change N lines

Deleting the Text


Command Description
x Delete character under cursor
Nx Delete N characters
dw Delete word from cursor
dNw Delete N words
D Delete from cursor to end of line
dd Delete current line
Ndd / dNd Delete N lines

Cutting and Pasting Text


Command Description
yy Yank (copy) current line
Nyy / yNy Yank next N lines including current
p Paste below current line

Searching the Text


Command Description
/string Search forward
?string Search backward
n Next match in same direction
N Next match in opposite direction

Determining Line Numbers


Command Description
:. Show current line number
:= Show total number of lines
^g Show current line number and total
lines

Saving and Reading Files


Command Description
:r filename Insert contents of file after current
line
:w Save file
:w newfile Save to a new file
:12,35w smallfile Save lines 12–35 to smallfile
:w! prevfile Overwrite and save to existing file

You might also like