LinuxCommandsFatma
LinuxCommandsFatma
1.echo
Purpose: The echo command outputs the text or strings and results of
computations to the terminal.
Example: fatma@Fatma:~$ echo "Hello"
Output: Hello
Page | 1
2.date
Purpose: The date command displays the current date and time.
Example: fatma@Fatma:~$ date
Output: Wed Nov 27 11:21:30 IST 2024
Specifiers like %m, %b, %y, etc., are used to customize formatting.
i. “date +%m”
Purpose: Displays the current month (numeric)
Example: fatma@Fatma:~$ date +%m
Output: 11
Page | 2
3.cal
Purpose: Displays a calendar for the current month
Example: fatma@Fatma:~$ cal
Output:
November 2024
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
4.who
Purpose: The who command displays the information of users currently logged
into the system. It returns the user’s ID/name, terminal, and the time at which he
or she logged in.
Example: fatma@Fatma:~$ who
Output: fatma :0 2024-12-03 11:21 (: 0)
i. “who -u”
Purpose: Displays information about currently logged-in users along with their
idle time and process ID (PID).
Example: fatma@Fatma:~$ who -u
Output: fatma :0 2024-12-03 08:30 00:25 5678 (: 0)
ii. “ whoami”
Purpose: Displays the name of the current user.
Example: fatma@Fatma:~$ whoami
Output: fatma
5.uname
Purpose: Using this command, we can know the details of the system. Certain
options like r, v, m, and a can be used with this command.
Example: fatma@Fatma:~$ uname
Output: Linux
i. uname -r
Page | 3
Purpose: Displays the kernel release version.
Example: fatma@Fatma:~$ uname -r
Output: 5.10.16.3-microsoft-standard-WSL2
ii. uname -m
Purpose: Displays the machine hardware architecture.
Example: fatma@Fatma:~$ uname -m
Output: x86_64
iii. uname -v
Purpose: Displays the kernel version and build information.
Example: fatma@Fatma:~$ uname -v
Output: #1 SMP Fri Apr 2 22:23:49 UTC 2021
iv. uname -a
Purpose: Displays all system information in the following order:
Kernel name, network node hostname, kernel release date, kernel version,
machine hardware, hardware platform, operating system.
6.cat
Purpose: Used to create small files and display the content of that file content.
i. cat > file_name.txt
Purpose: Creates the file.
Example: fatma@Fatma:~$ cat > test.txt
This is a text file created using 'cat'
^C
fatma@Fatma:~$
Page | 4
Purpose: Clears all the text from the terminal screen.
Example: fatma@Fatma:~$ clear
Output: (Cleared terminal)
8.history
Purpose: It shows history if the commands used in the terminal.
Example: fatma@Fatma:~$ history
Output: 1 uname
2 uname -r
3 uname -m
4 uname -v
5 uname -a
6 cat > test.txt
7 cat test.txt
8 clear
9 pwd
10 history ….. and so on
9.pwd
Purpose: The ‘pwd’ command displays the absolute path of the current directory.
Example: fatma@Fatma:~$ pwd
Output: /home/fatma
10. mkdir
Purpose: The ‘mkdir’ command is used to create new directory.
Example: fatma@Fatma:~$ mkdir OS
Output: (Creates a directory named ‘OS’)
11. ls
Purpose: Lists the files and directories in the current or specified directory.
Example: fatma@Fatma:~$ ls
Output: OS a.out childpid.c hello.sh hello2.c killchild.c pid.c test.sh
test2.sh ShellScripts child.c hello.c hello1.c hello3.c multiply.c processId.c
12. cd
Page | 5
Purpose: Change the current working directory to the specified one.
Example: fatma@Fatma:~$ cd OS
Output: fatma@Fatma:~/OS$
13. rmdir
Purpose: Removes a directory.
Example: fatma@Fatma:~$ rmdir OS
Output: (The directory ‘OS’ is removed)
14. ps
Purpose: Displays running processes for the current shell.
Example: fatma@Fatma:~$ ps
Output:
PID TTY TIME CMD
9 pts/0 00:00:00 bash
527 s/0 00:00:00 ps
15. ps -awx
Purpose: Displays running processes for the current shell.
Example: fatma@Fatma:~$ ps
Output:
PID TTY STAT TIME COMMAND
1? Sl 0:00 /init
7? Ss 0:00 /init
8? R 0:00 /init
9 pts/0 Ss 0:00 -bash
544 s/0 R+ 0:00 ps -awx
16. ls -l
Page | 6
Purpose: The ls -l command in Linux is used to list the files and directories in the
current directory with detailed information, including file permissions, ownership,
size, and timestamps.
Example: fatma@Fatma:~$ ls -l
Output:
total 88
drwxr-xr-x 2 fatma fatma 4096 Nov 23 19:35 OS
drwxr-xr-x 2 fatma fatma 4096 Nov 24 19:16 ShellScripts
drwxr-xr-x 2 fatma fatma 4096 Dec 3 20:17 Test
-rwxr-xr-x 1 fatma fatma 16176 Nov 24 17:50 a.out
-rw-r--r-- 1 fatma fatma 237 Nov 23 17:15 child7.c
-rw-r--r-- 1 fatma fatma 196 Nov 24 00:23 childpid.c
-rw-r--r-- 1 fatma fatma 116 Nov 23 16:49 hello.c
-rwxr-xr-x 1 fatma fatma 34 Nov 21 13:06 hello.sh
-rw-r--r-- 1 fatma fatma 115 Nov 23 13:24 hello1.c
-rw-r--r-- 1 fatma fatma 124 Nov 23 13:24 hello2.c
-rw-r--r-- 1 fatma fatma 133 Nov 23 13:27 hello3.c
-rw-r--r-- 1 fatma fatma 291 Nov 24 17:50 killchild.c
-rw-r--r-- 1 fatma fatma 310 Nov 23 16:57 multiply.c
-rw-r--r-- 1 fatma fatma 221 Nov 23 13:17 pid.c
-rw-r--r-- 1 fatma fatma 392 Nov 23 16:43 processId.c
-rwxrwxrwx 1 fatma fatma 111 Nov 24 18:03 test.sh
-rw-r--r-- 1 fatma fatma 40 Dec 3 19:53 test.txt
-rwxrwxrwx 1 fatma fatma 50 Nov 24 18:21 test2.sh
-rwxrwxrwx 1 fatma fatma 52 Nov 24 18:26 test3.sh
17. chmod
Purpose: The ‘chmod’ command is used to change the permissions of a file or
directory in Linux. Permissions determine who can read, write, or execute a file.
Page | 7
Example: fatma@Fatma:~$ chmod 744 test.txt
(This sets the permissions for the file ‘test.txt’)
Page | 8