0% found this document useful (0 votes)
4 views

431_Assignment2(OSL) (1)

This document provides a comprehensive overview of various UNIX commands, including their usage and examples. Key commands covered include 'man', 'cat', 'ls', 'pwd', 'cd', 'mkdir', 'cp', 'rm', 'mv', 'chmod', 'du', 'df', and others, detailing their functionalities. The document serves as a practical guide for performing file and directory operations in a UNIX environment.

Uploaded by

meemee0101000
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

431_Assignment2(OSL) (1)

This document provides a comprehensive overview of various UNIX commands, including their usage and examples. Key commands covered include 'man', 'cat', 'ls', 'pwd', 'cd', 'mkdir', 'cp', 'rm', 'mv', 'chmod', 'du', 'df', and others, detailing their functionalities. The document serves as a practical guide for performing file and directory operations in a UNIX environment.

Uploaded by

meemee0101000
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Assignment 2

(UNIX Commands)
UCE2023431
Eesha Kamath
A2

man - manual listing of all commands, system calls, and other documented parts of unix

cat - display the entered input


localhost:~$ cat
assignment
assignment

z + tab tab - display all linux commands


localhost:~$ z
zcat zdiff zfgrep zgrep zmore zramctl zsh-5.8
zcmp zegrep zforce zless znew zsh

cat - display file content


localhost:~$ cat upload.txt
this is a text file with name "upload" to be uploaded
.

ls - list files (-F special files, programs, directories)


localhost:~$ ls /
bin etc lib mnt proc run srv tmp var
dev home media opt root sbin sys usr
localhost:~$ ls -F /
bin/ etc/ lib/ mnt/ proc/ run/ srv/ tmp/ var/
dev/ home/ media/ opt/ root/ sbin/ sys/ usr/

ls -l - displays all details of the list of files


localhost:~$ ls -l
total 8
-rw------- 1 eeshakam root 18 Jan 8 15:09 text.txt
-rw------- 1 eeshakam root 58 Jan 8 15:22 upload.txt
-rw------- 1 eeshakam root 0 Jan 8 15:06 word.docx

pwd - present working directory


localhost:~$ pwd
/home/eeshakamath11
localhost:/home$ pwd
/home
localhost:/home$

cd - change directory
mkdir - makes new directory
localhost:/home$ cd /home/eeshakamath11
localhost:~$ pwd
/home/eeshakamath11
localhost:~$ mkdir new
localhost:~$ cd new
localhost:~/new$

cp - copy
localhost:~$ cp upload.txt word.docx
localhost:~$ cat word.docx
this is a text file with name "upload" to be uploaded
.

rm - removes the file from the directory


localhost:~$ rm text.txt
localhost:~$ ls -l
total 12
drwxr-xr-x 2 eeshakam user2 37 Jan 8 15:33 new
-rw------- 1 eeshakam root 58 Jan 8 15:22 upload.txt
-rw------- 1 eeshakam user2 58 Jan 8 15:36 word.docx

rmdir - removes directory


localhost:~$ rmdir new
localhost:~$ ls -l
total 8
-rw------- 1 eeshakam root 58 Jan 8 15:22 upload.txt
-rw------- 1 eeshakam user2 58 Jan 8 15:36 word.docx

mv - moves files (copies and deletes)


localhost:~$ mkdir new_folder
localhost:~$ mv word.docx new_folder
localhost:~$ cd new_folder
localhost:~/new_folder$ ls -l
total 4
-rw------- 1 eeshakam user2 58 Jan 8 15:36 word.docx
localhost:~/new_folder$ cd /home/eeshakamath11
localhost:~$ ls -l
total 8
drwxr-xr-x 2 eeshakam user2 63 Jan 8 15:41 new_folder
-rw------- 1 eeshakam root 58 Jan 8 15:22 upload.txt
touch - updates the time of the file to current time
localhost:~$ touch upload.txt
localhost:~$ ls -l
total 8
drwxr-xr-x 2 eeshakam user2 63 Jan 8 15:41 new_folder
-rw------- 1 eeshakam root 58 Jan 8 15:50 upload.txt
localhost:~$ touch newfile.txt
localhost:~$ ls -l
total 8
drwxr-xr-x 2 eeshakam user2 63 Jan 8 15:41 new_folder
-rw-r--r-- 1 eeshakam user2 0 Jan 8 15:51 newfile.txt
-rw------- 1 eeshakam root 58 Jan 8 15:50 upload.txt

chmod - change permissions on a file


localhost:~$ chmod 754 upload.txt
localhost:~$ ls -l
total 8
drwxr-xr-x 2 eeshakam user2 63 Jan 8 15:41 new_folder
-rw-r--r-- 1 eeshakam user2 0 Jan 8 15:51 newfile.txt
-rwxr-xr-- 1 eeshakam root 58 Jan 8 15:50 upload.txt

du - disk usage (amount of disk space)


df - disk filling (details of the current filling disk)
uptime - active time
localhost:~$ du
20 ./.vfsync
8 ./new_folder
40 .
localhost:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 5120000 2417736 2702264 47% /
devtmpfs 93464 0 93464 0% /dev
tmpfs 93620 4 93616 0% /run
none 93620 0 93620 0% /dev/shm
localhost:~$ uptime

who - displays current users of the system


localhost:~$ who
/bin/sh: who: not found
localhost:~$ who am i
/bin/sh: who: not found

cat =>
localhost:~$ cat upload.txt
this is a text file with name "upload" to be uploaded
.

-n => number of lines


-A => control characters
localhost:~$ cat -n upload.txt
1 this is a text file with name "upload" to be uploaded
2 .
localhost:~$ cat -A upload.txt
this is a text file with name "upload" to be uploaded^M$
.^M$
localhost:~$ cat -nA upload.txt
1 this is a text file with name "upload" to be uploaded^M$
2 .^M$

more - strats on the specified line number


localhost:~$ more -l +1 upload.txt
this is a text file with name "upload" to be uploaded
.
localhost:~$ more -l +2 upload.txt
.

head - displays the mentioned number of lines from the start


localhost:~$ head -5 word.txt
line 1
line 2
line 3
line 4
line 5
localhost:~$ head -1 word.txt upload.txt
==> word.txt <==
line 1

==> upload.txt <==


this is a text file with name "upload" to be uploaded

tail - displays the mentioned number of lines from the end


localhost:~$ tail -1 word.txt upload.txt
==> word.txt <==
line 10

==> upload.txt <==


.

file - gives format of the file


localhost:~$ file upload.txt word.txt
upload.txt: ASCII text, with CRLF line terminators
word.txt: ASCII text, with CRLF line terminators

grep - generalized regular expression parser - search text line


localhost:~$ grep -n "line" word.txt
1:line 1
2:line 2
3:line 3
4:line 4
5:line 5
6:line 6
7:line 7
8:line 8
9:line 9
10:line 10
localhost:~$ grep "name" upload.txt
this is a text file with name "upload" to be uploaded

wc - word count
localhost:~$ wc word.txt
10 20 81 word.txt

spell - find s the mispelt words


localhost:~$ spell upload.txt
/bin/sh: spell: not found
(misspelt words not found)

cmp - compares 2 files and gives the start line that is not matching
localhost:~$ cmp upload.txt newfile.txt
cmp: EOF on newfile.txt
localhost:~$ cmp upload.txt word.txt
upload.txt word.txt differ: char 1, line 1
localhost:~$ cmp upload.txt
this is inthe input give
upload.txt - differ: char 9, line 1

diff - compares and gives detailed differences


localhost:~$ diff upload.txt word.txt
--- upload.txt
+++ word.txt
@@ -1,2 +1,10 @@
-this is a text file with name "upload" to be uploaded
-.
+line 1
+line 2
+line 3
+line 4
+line 5
+line 6
+line 7
+line 8
+line 9
+line 10
localhost:~$ diff upload.txt newfile.txt
--- upload.txt
+++ newfile.txt
@@ -1,2 +0,0 @@
-this is a text file with name "upload" to be uploaded
-.

gzip - compress (.gz)


gunzip - decompress
localhost:~$ gzip word.txt
localhost:~$ ls -lh
total 12K
drwxr-xr-x 2 eeshakam user2 63 Jan 8 15:41 new_folder
-rw-r--r-- 1 eeshakam user2 0 Jan 8 15:51 newfile.txt
-rwxr-xr-- 1 eeshakam user2 58 Jan 8 15:50 upload.txt
-rw------- 1 eeshakam user2 64 Jan 15 15:10 word.txt.gz
localhost:~$ gunzip word.txt
localhost:~$ ls -lh
total 12K
drwxr-xr-x 2 eeshakam user2 63 Jan 8 15:41 new_folder
-rw-r--r-- 1 eeshakam user2 0 Jan 8 15:51 newfile.txt
-rwxr-xr-- 1 eeshakam user2 58 Jan 8 15:50 upload.txt
-rw------- 1 eeshakam user2 81 Jan 15 15:10 word.txt

tr -translate (replaces all occurences of string1 in the input string2)


localhost:~$ tr 'line' 'LINE'>word.txt

You might also like