Linux Report
Linux Report
24
INPUT:-
sdb@bond007:~$ pwd
OUTPUT:-
/home/sdb
OUTPUT:-
Desktop Downloads Pictures snap Videos
Documents Music Public Templates
3. ‘ls -l’- lists all the types of files in the active directory with much more
information
INPUT:-
sdb@bond007:~$ ls -l
OUTPUT:-
total 36
drwxr-xr-x 3 sdb sdb 4096 Jan 16 00:34 Desktop
drwxr-xr-x 2 sdb sdb 4096 Jan 16 00:14 Documents
drwxr-xr-x 2 sdb sdb 4096 Jan 16 00:14 Downloads
drwxr-xr-x 2 sdb sdb 4096 Jan 16 00:14 Music
drwxr-xr-x 2 sdb sdb 4096 Jan 16 00:14 Pictures
drwxr-xr-x 2 sdb sdb 4096 Jan 16 00:14 Public
drwx------ 4 sdb sdb 4096 Jan 16 22:12 snap
drwxr-xr-x 2 sdb sdb 4096 Jan 16 00:14 Templates
drwxr-xr-x 2 sdb sdb 4096 Jan 16 00:14 Videos
OUTPUT:-
sdb@bond007:~/Documents$
5. ‘mkdir’-making of new directory
OUTPUT:-
sdb@bond007:~/Documents$ ls
soham
INPUT:-
sdb@bond007:~/Documents$ cd ..
OUTPUT:-
sdb@bond007:~$
INPUT:-
sdb@bond007:~/Documents/soham$ cd ~
OUTPUT:-
sdb@bond007:~$
8. ‘cd /’-changes to root directory ‘ls -a’- shows hidden files in the active directory
INPUT:-
sdb@bond007:~$ cd /
OUTPUT:-
sdb@bond007:/$
INPUT:-
sdb@bond007:/$ ls-a
OUTPUT:-
. bin cdrom etc lib media opt root sbin srv sys usr
.. boot dev home lost+found mnt proc run snap swapfile tmp var
10. ‘ls -la’- shows hidden files in the active directory with much more information
INPUT:-
sdb@bond007:/$ ls-la
OUTPUT:-
total 1648728
drwxr-xr-x 20 root root 4096 Jan 16 00:06 .
drwxr-xr-x 20 root root 4096 Jan 16 00:06 ..
lrwxrwxrwx 1 root root 7 Jan 16 00:05 bin -> usr/bin
drwxr-xr-x 4 root root 4096 Jan 16 00:08 boot
drwxr-xr-x 2 root root 4096 Jan 16 00:06 cdrom
drwxr-xr-x 19 root root 4000 Jan 18 00:47 dev
drwxr-xr-x 126 root root 12288 Jan 16 00:18 etc
drwxr-xr-x 3 root root 4096 Jan 16 00:07 home
lrwxrwxrwx 1 root root 7 Jan 16 00:05 lib -> usr/lib
drwx------ 2 root root 16384 Jan 16 00:04 lost+found
drwxr-xr-x 2 root root 4096 Jan 15 13:25 media
drwxr-xr-x 2 root root 4096 Jan 15 13:25 mnt
drwxr-xr-x 2 root root 4096 Jan 15 13:25 opt
dr-xr-xr-x 239 root root 0 Jan 18 00:47 proc
drwx------ 4 root root 4096 Jan 16 00:14 root
drwxr-xr-x 35 root root 920 Jan 18 01:17 run
lrwxrwxrwx 1 root root 8 Jan 16 00:05 sbin -> usr/sbin
drwxr-xr-x 11 root root 4096 Jan 15 13:35 snap
drwxr-xr-x 2 root root 4096 Jan 15 13:25 srv
-rw------- 1 root root 1688207360 Jan 16 00:04 swapfile
dr-xr-xr-x 13 root root 0 Jan 18 00:47 sys
drwxrwxrwt 19 root root 4096 Jan 18 01:17 tmp
drwxr-xr-x 11 root root 4096 Jan 15 13:25 usr
drwxr-xr-x 14 root root 4096 Jan 15 13:33 var
Date: 18.01.24
11. ‘ls -lh’- displays all files in the active directory with human readable storage
information
INPUT:-
sdb@bond007:~$ ls -lh
OUTPUT:-
total 44K
drwxr-xr-x 2 sdb sdb 4.0K Jan 24 21:18 Desktop
drwxr-xr-x 5 sdb sdb 4.0K Jan 18 14:27 Documents
drwxr-xr-x 2 sdb sdb 4.0K Jan 16 00:14 Downloads
drwxrwxr-x 4 sdb sdb 4.0K Jan 18 16:04 MIC
drwxr-xr-x 2 sdb sdb 4.0K Jan 16 00:14 Music
drwxr-xr-x 2 sdb sdb 4.0K Jan 16 00:14 Pictures
drwxr-xr-x 2 sdb sdb 4.0K Jan 16 00:14 Public
drwx------ 4 sdb sdb 4.0K Jan 16 22:12 snap
drwxrwxr-x 2 sdb sdb 4.0K Jan 18 14:26 temp
drwxr-xr-x 2 sdb sdb 4.0K Jan 16 00:14 Templates
drwxr-xr-x 2 sdb sdb 4.0K Jan 16 00:14 Videos
INPUT:-
sdb@bond007:~/MIC$ touch file1
sdb@bond007:~/MIC$ ls
file1
INPUT:-
sdb@bond007:~/MIC$ nano file1
sdb@bond007:~/MIC$ cat file1
OUTPUT:-
a
b
c
d
15. ‘cat file1 file2’- display the contents of the files in a series
INPUT:- (creating another file named as file2 and using nano editor to edit the file)
OUTPUT:-
a
b
c
d
1
2
3
4
16. ‘cat >’- copies the contents of the files in a new file
INPUT:-
sdb@bond007:~/MIC$ cat file1 file2 > file3
sdb@bond007:~/MIC$ cat file3
OUTPUT:-
a
b
c
d
1
2
3
4
17. ‘cat -n’- display the contents of the file with line numbers
INPUT:-
sdb@bond007:~/MIC$ cat -n file3
OUTPUT:-
1 a
2 b
3 c
4 d
5 1
6 2
7 3
8 4
18. ‘cat >>’- appends the file information of one file to another i.e. it concatenates
the information of one file to another
INPUT:-
sdb@bond007:~/MIC$ cat file1 >>file2
sdb@bond007:~/MIC$ cat file2
OUTPUT:-
1
2
3
a
b
c
d
INPUT:-
sdb@bond007:~/MIC$ echo "Hello World"
OUTPUT:-
Hello World
20. ‘$ name’- saves the value of the string “Hello World” to the variable ‘name’
INPUT:-
sdb@bond007:~/MIC$ name="SDB"
sdb@bond007:~/MIC$ echo "Hello $name"
OUTPUT:-
Hello SDB
INPUT:-
sdb@bond007:~/MIC$ echo -e "1\n2\n3"
OUTPUT:-
1
2
3
OUTPUT:-
Linux bond007 6.5.0-14-generic #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20
20:26:31 UTC 2 aarch64 aarch64 aarch64 GNU/Linux
INPUT:-
sdb@bond007:~/MIC$ rmdir MIC/
sdb@bond007:~/MIC$ ls
OUTPUT:-
file1 file11 file2 file3 greetings.txt MBT
23. ‘rm -r’- used to remove both empty and non-empty directories and files also
INPUT:-
sdb@bond007:~/MIC$ rm -r MBT/
sdb@bond007:~/MIC$ ls
OUTPUT:-
file1 file11 file2 file3 greetings.txt
INPUT:-
sdb@bond007:~/MIC$ rmdir -v MIC MBT
OUTPUT:-
rmdir: removing directory, 'MIC'
rmdir: removing directory, 'MBT'
INPUT:-
sdb@bond007:~/MIC$ rm file1
sdb@bond007:~/MIC$ ls
OUTPUT:-
file11 file2 file3 greetings.txt
INPUT:-
sdb@bond007:~/MIC$ rm -i file2
OUTPUT:-
rm: remove regular file 'file2'? y
INPUT:-
sdb@bond007:~/MIC$ rm file*
sdb@bond007:~/MIC$ ls
OUTPUT:-
greetings.txt
28. ‘rm -ir’- removes empty and non-empty directories with interactive mode
INPUT:-
sdb@bond007:~/MIC$ rm -ir MIC
OUTPUT:-
rm: remove directory 'MIC'? y
29. ‘rm -rv’- removes empty and non-empty directories with a visual conformation
INPUT:-
sdb@bond007:~/MIC$ rm -rv MIC
OUTPUT:-
removed directory 'MIC'
30. ‘rm -v !()’- removes all files except the mentioned file in the parenthesis
INPUT:-
sdb@bond007:~/MIC$ rm -v !(greetings.txt)
OUTPUT:-
removed 'file1.txt'
removed 'file2.txt'
removed 'file3.txt'