Nothing Scribd
Nothing Scribd
1.1 pwd
pwd (print working directory) displays the current working directory of the
user. When we first log into our system, our current directory is set to our
home directory.
$ pwd
/ home / user
1.2 ls
ls is used to list the files and directories in current working directory.
$ ls
Desktop Documents Music Pictures Public Templates Videos
1
$ ls -l
drwxrwxr - x 2 user user 4096 2023 -9 -26 17:23 Desktop
drwxrwxr - x 2 user user 93920 2023 -9 -26 17:21 Documents
drwxrwxr - x 2 user user 2041 2023 -9 -26 17:22 Music
$ ls - al
drwxrwxr - x 2 user user 4096 2023 -9 -26 17:19 .
drwxrwxr - x 2 user user 4096 2023 -9 -26 17:20 ..
drwxrwxr - x 2 user user 4096 2023 -9 -26 17:23 Desktop
drwxrwxr - x 2 user user 93920 2023 -9 -26 17:21 Documents
drwxrwxr - x 2 user user 2041 2023 -9 -26 17:22 Music
$ ls - lt
drwxrwxr - x 2 user user 4096 2023 -9 -26 17:23 Desktop
drwxrwxr - x 2 user user 2041 2023 -9 -26 17:22 Music
drwxrwxr - x 2 user user 93920 2023 -9 -26 17:21 Documents
$ ls - lS
drwxrwxr - x 2 user user 93920 2023 -9 -26 17:21 Documents
drwxrwxr - x 2 user user 4096 2023 -9 -26 17:23 Desktop
drwxrwxr - x 2 user user 2041 2023 -9 -26 17:22 Music
$ ls - lh
drwxrwxr - x 2 user user 4.0 K 2023 -9 -26 17:23 Desktop
drwxrwxr - x 2 user user 93 K 2023 -9 -26 17:21 Documents
drwxrwxr - x 2 user user 2.0 K 2023 -9 -26 17:22 Music
1.3 cd
cd changes our current working directory to the specified directory or path.
$ cd / usr / bin
$ pwd
/ usr / bin
1.4 cat
cat command reads one or more files and copies the content to the standard
output.
$ cat output . txt
The quick brown fox jumped over the lazy dog .
2
• -s: compresses consecutive blank lines and only shows a single one
1.6 mkdir
mkdir command created new directory with specified file name or pathname.
$ mkdir test
$ ls
Desktop Documents Music Pictures Public Templates Videos test
3
If we specify -p option to the mkdir command, it will also create the
non-existing parent directories.
$ ls
Desktop Documents Music Pictures Public Templates Videos
$ mkdir -p dir1 / dir2 / dir3
$ ls
$ ls
Desktop Documents Music Pictures Public Templates Videos dir1
$ cd dir1
$ ls
dir2
$ cd dir2
$ ls
dir3
$ ls
Desktop Documents Music Pictures Public Templates Videos test
$ rmdir test
$ ls
Desktop Documents Music Pictures Public Templates Videos
1.8 cp
cp command copies specified file(s) contents to a specified file or pathname.
4
$ cat a . txt
The quick brown fox
$ cat b . txt
jumped over the lazy dog .
$ cp a . txt out . txt
$ cat out . txt
The quick brown fox
$ cat a . txt b . txt Documents
$ cd Documents
$ ls Documents
a . txt b . txt
• -i: before overwriting an existing file, prompts the user for confirma-
tion
1.9 mv
mv command performs both moving and renaming operation.
$ ls
Desktop Documents Music Pictures Public Templates Videos test
$ mv test Documents
$ ls Documents
test
$ mv Templates Temps
$ ls
Desktop Documents Music Pictures Public Temps Videos
1.9 less
less command shows the contents of specified file page by page. And also
provide with powerful navigation and searching capabilities.
$ less a . cpp
5
1.11 touch
touch command is usually used to change access, change and modify time
of a file. If the specified file does not exist, then touch command creates a
blank file with the specified name.
$ ls
Desktop Documents Music Pictures Public Templates Videos
$ touch newfile
$ ls - lh newfile
drwxrwxr - x 2 user user 0 B 2023 -9 -26 17:30 newfile
$ touch newfile
drwxrwxr - x 2 user user 2041 2023 -9 -26 17:32 newfile
1.12 nano
nano command starts up a basic editor. Where specifying a file, nano opens
up the file for editing with minimal features.
$ nano a . cpp
6
1.13 sudo
sudo command lets regular user become super user to do administrative
operations or change system settings, install system wide softwares etc.
$ sudo apt install gcc
1.14 top
top command displays a continuously updating (by default, every three sec-
onds) display of the system processes listed in order of process activity.
$ top
1.15 kill
kill command is used to send signals to programs. Such as, terminate,
stop, continue etc.
$ kill 2746
7
1.16 echo
echo command writes all the given strings to the standard output with spaces
in between and a newline after the last given string.
$ echo The quick brown fox jumped over the lazy dog .
The quick brown fox jumped over the lazy dog .
1.17 file
file command shows information about the file type of the specified file.
$ file a . cpp
a . cpp : C ++ source , ASCII text
$ file test . png
test . png : PNG image data , 563 x 137 , 8 - bit / color RGBA ,
non - interlaced
1.18 chmod
chmod command is used to change a file or directory read-write permission
for any user. Only the file’s owner or the superuser can change the mode
of a file or directory. chmod supports two distinct ways of specifying mode
changes: octal number representation, or symbolic representation
$ touch foo . txt
$ ls -l foo . txt
-rw - rw -r - - 1 user user 0 2023 -09 -26 17:52 foo . txt
$ chmod 600 foo . txt
$ ls -l foo . txt
-rw - - - - - - - 1 user user 0 2023 -09 -26 17:53 foo . txt
$ chmod 375 foo . txt
$ ls -l foo . txt
-- wxrwxr - x 1 user user 0 2023 -09 -26 17:53 foo . txt
1.19 ps
ps command shows the processes associated with the current terminal ses-
sion.
8
$ ps
PID TTY TIME CMD
4569 pts /1 00:00:04 zsh
16447 pts /1 00:00:00 ps