You are on page 1of 17

MOHAMED AHMED IBRAHIM

DUBAI - UAE

Important Linux
Command
Of course, we can’t just skip studying Linux Commands after taking a tour with the
Microsoft “DOS” Commands in the previous post. macOS and Linux have a massive number
of built-in command-line utilities. Which you could spend the rest of your life learning all of
the Terminal commands!
But, in here we just going to introduce you to the Basic Linux Commands, which have been
covered by CompTIA A+, and may be a little beyond that.

To open Terminal window on Linux;


 Launch the terminal by pressing Ctrl+ Alt+ T
 Or just click on the terminal icon in the task bar.

Linux terminal color code: 2C001E

Linux terminal help tools;


$ [command] -h / - Displays the complete usage of that command.
-help
$ [com*] press tab Displays all commands that include the letters you typed.
twice
$ help the simplest way to get information regarding a built-in shell
command
$ help cd Displays everything we want to know about “cd” command.
$ help -d cd -d (display only a brief description of the specified command).
$ help -m cd -m (organize the available information just as the man
$ help -s cd command does).
-s (display the command syntax of the specified command).
$ man [command] Enable you to read a manual page about a specific command.
Here
$ info Gives detailed information for a command when compared
with the man page.
$ whatis [command] Gives you a description of the specified command.
$ sudo lshw Displays the Device Hardware components.
$ sudo lshw -short Prints a summary of your hardware information.
“Q” button / ctrl To exit the page.
+ C
$ clear To clear the terminal window.
STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM
MOHAMED AHMED IBRAHIM
DUBAI - UAE

Hint; the Linux Terminal is case-sensitive.

To run a command as administrator (user "root"), use "sudo <command>".


See "man sudo_root" for details.

-h --help
mohamed@mohamed-VM:~/Desktop$ cal -h
Usage: cal [general options] [-jy] [[month] year]
cal [general options] [-j] [-m month] [year]
ncal -C [general options] [-jy] [[month] year]
ncal -C [general options] [-j] [-m month] [year]
ncal [general options] [-bhJjpwySM] [-H yyyy-mm-dd] [-s country_code] [[month]
year]
ncal [general options] [-bhJeoSM] [year]
General options: [-31] [-A months] [-B months] [-d yyyy-mm]

Press “tab” twice;


mohamed@m ohamed-VM:~/Desktop$ ca
cal calibrate_ppa canberra-gtk-play capsh case
catchsegv cautious-launcher
calendar caller cancel captoinfo cat
catman

$ help cd;
mohamed@mohamed-VM:~/Desktop$ help cd
cd: cd [-L|[-P [-e]] [-@]] [dir]
Change the shell working directory.

Change the current directory to DIR. The default DIR is the value of the
HOME shell variable.

The variable CDPATH defines the search path for the directory containing
DIR. Alternative directory names in CDPATH are separated by a colon (:).
A null directory name is the same as the current directory. If DIR begins
with a slash (/), then CDPATH is not used.

If the directory is not found, and the shell option `cdable_vars' is set,
the word is assumed to be a variable name. If that variable has a value,
its value is used for DIR.

Options:
-L force symbolic links to be followed: resolve symbolic
links in DIR after processing instances of `..'
-P use the physical directory structure without
following symbolic links: resolve symbolic links in

STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM


MOHAMED AHMED IBRAHIM
DUBAI - UAE

DIR before

STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM


MOHAMED AHMED IBRAHIM
DUBAI - UAE

processing instances of `..'


-e if the -P option is supplied, and the current working directory cannot be determine
on systems that support it, present a file with extended attributes as a directory

-@

The default is to follow symbolic links, as if `-L' were specified.


`..' is processed by removing the immediately previous pathname component back to a slash o

Exit Status:
Returns 0 if the directory is changed, and if $PWD is set successfully when
-P is used; non-zero otherwise.

-d, -s;
mohamed@mohamed-VM:~/Desktop$ help -d cd
cd - Change the shell working directory.

mohamed@mohamed-VM:~/Desktop$ help -s cd
cd: cd [-L|[-P [-e]] [-@]] [dir]

man;
mohamed@mohamed-VM:~/Desktop$ man cal

CAL(1) BSD General Commands Manual

NAME
cal, ncal — displays a calendar and the date of Easter

SYNOPSIS
cal [-31jy] [-A number] [-B number] [-d yyyy-mm] [[month] year]
cal [-31j] [-A number] [-B number] [-d yyyy-mm] -m month [year]
ncal [-C] [-31jy] [-A number] [-B number] [-d yyyy-mm] [[month] year]
ncal [-C] [-31j] [-A number] [-B number] [-d yyyy-mm] -m month [year]
ncal [-31bhjJpwySM] [-A number] [-B number] [-H yyyy-mm-dd] [-d yyyy-mm] [-s
country_code] [[month] year]
ncal [-31bhJeoSM] [-A number] [-B number] [-d yyyy-mm] [year]

DESCRIPTION
The cal utility displays a simple calendar in traditional format and ncal offers an
alternative layout, more options and the date of
Easter. The new format is a little cramped but it makes a year fit on a 25x80 terminal.
If arguments are not specified, the cur‐
rent month is displayed.

The options are as follows:

-h Turns off highlighting of today.

STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM


MOHAMED AHMED IBRAHIM
DUBAI - UAE

-J Display Julian Calendar, if combined with the -o option, display date of Orthodox
Easter according to the Julian Calendar.

-e Display date of Easter (for western churches).

-j Display Julian days (days one-based, numbered from January 1).

Manual page cal(1) line 1 (press h for help or q to quit)

info;
mohamed@mohamed-VM:~/Desktop$ info bash

BASH(1) General Commands Manual

NAME
bash - GNU Bourne-Again SHell

SYNOPSIS
bash [options] [command_string | file]

COPYRIGHT
Bash is Copyright (C) 1989-2018 by the Free Software Foundation, Inc.

DESCRIPTION
Bash is an sh-compatible command language interpreter that executes commands read
from the standard input or from a file. Bash
also incorporates useful features from the Korn and C shells (ksh and csh).

Bash is intended to be a conformant implementation of the Shell and Utilities portion


of the IEEE POSIX specification (IEEE Stan‐
dard 1003.1). Bash can be configured to be POSIX-conformant by default.

OPTIONS
All of the single-character shell options documented in the description of the set
builtin command, including -o, can be used as
options when the shell is invoked. In addition, bash interprets the following options
when it is invoked:

-c If the -c option is present, then commands are read from the first non-option
argument command_string. If there are ar‐
guments after the command_string, the first argument is assigned to $0 and
any remaining arguments are assigned to the
positional parameters. The assignment to $0 sets the name of the shell,
which is used in warning and error messages.
-i If the -i option is present, the shell is interactive.
-l Make bash act as if it had been invoked as a login shell (see
INVOCATION below).
Info: (*manpages*)bash, 4136 lines Top

STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM


MOHAMED AHMED IBRAHIM
DUBAI - UAE

whatis;
mohamed@mohamed-VM:~/Desktop$ whatis cal
cal (1)- displays a calendar and the date of Easter
mohamed@mohamed-VM:~/Desktop$ cal 2022 ‫أكتوبر‬
‫ح ن ث ر خ ج س‬
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 31
mohamed@mohamed-VM:~/Desktop$

sudo lshw;
mohamed@mohamed-VM:~/Desktop$ sudo lshw
[sudo] password for mohamed:
mohamed-vm
description: Computer
product: VMware Virtual Platform
vendor: VMware, Inc.
version: None
serial: VMware-56 4d d4 46 27 6b cc e4-6b d4 d8 6f fa 5f 06 ca
width: 64 bits
capabilities: smbios-2.7 dmi-2.7 smp vsyscall32
configuration: administrator_password=enabled boot=normal
frontpanel_password=unknown keyboard_password=unknown power-
on_password=disabled uuid=564DD446-276B-CCE4-6BD4-D86FFA5F06CA
*-core
description: Motherboard
product: 440BX Desktop Reference Platform
vendor: Intel Corporation
physical id: 0
version: None
serial: None
*-firmware
description: BIOS
vendor: Phoenix Technologies LTD
physical id: 0
version: 6.00
date: 11/12/2020
size: 86KiB

STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM


MOHAMED AHMED IBRAHIM
DUBAI - UAE

Linux commands;
$ ls Display the directories and files.
$ ls -l | more Displays file’s ownership and permissions.
| more, enables you to see the output page by page.
$ cd “/” To change the directory.
$ cd ~ “cd ~” takes you to the home directory.
$ grep <pattern> To look for a text in a file (search).
[file]
$ ps aux | grep Grep in here is used to filter the output (filter).
“pattern”
$ su Elevates the privilege to Super User, until you exit the mode.
$ sudo “sudo” enables you to run a single command in the Privilege
mode and then get you back to the normal mode.

ls;
mohamed@mohamed-VM:/var/log$ ls -l
total 2604
-rw-r--r-- 1 root root 33052 Oct 5 15:54 alternatives.log
drwxr-xr-x 2 root root 4096 Oct 5 15:49 apt
-rw-r----- 1 syslog adm 10436 Oct 5 17:56 auth.log
-rw------- 1 root root 9137 Oct 5 14:54 boot.log
drwxr-xr-x 2 root root 4096 Oct 5 14:54 cups
drwxr-xr-x 2 root root 4096 Feb 8 2022 dist-upgrade
-rw-r--r-- 1 root adm 131892 Oct 5 15:52 dmesg
-rw-r--r-- 1 root root 10973 Oct 5 15:54 fontconfig.log
drwx--x--x 2 root gdm 4096 Jul 12 2021 gdm3
-rw-r--r-- 1 root root 1478 Oct 5 14:54 gpu-manager.log
drwxr-xr-x 3 root root 4096 Feb 23 2022 hp
drwxrwxr-x 2 root root 4096 Oct 5 14:42 installer

cd;
mohamed@mohamed-VM:~$ cd Documents/
mohamed@mohamed-VM:~/Documents$
Hint; we use the forward-slash “/” to specify the path with Linux, not the back-slash as in
windows.
Hint; the Linux Terminal is case-sensitive.

cd ~;
mohamed@mohamed-VM:/var/log cd ~

STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM


MOHAMED AHMED IBRAHIM
DUBAI - UAE

mohamed@mohamed-VM:~$

grep;
mohamed@mohamed-VM:/var/log$ grep Bluetooth dmesg
[ 2.771074] kernel: usb 2-2.1: Product: Virtual Bluetooth Adapter
[ 6.165141] kernel: Bluetooth: Core ver 2.22
[ 6.165165] kernel: Bluetooth: HCI device and connection manager initialized
[ 6.165169] kernel: Bluetooth: HCI socket layer initialized
[ 6.165171] kernel: Bluetooth: L2CAP socket layer initialized
[ 6.165175] kernel: Bluetooth: SCO socket layer initialized
[ 17.468829] kernel: Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 17.468834] kernel: Bluetooth: BNEP filters: protocol multicast
[ 17.468839] kernel: Bluetooth: BNEP socket layer initialized
[ 150.925637] kernel: Bluetooth: RFCOMM TTY layer initialized
[ 150.925645] kernel: Bluetooth: RFCOMM socket layer initialized
[ 150.925649] kernel: Bluetooth: RFCOMM ver 1.11

| grep;
mohamed@mohamed-VM:~$ ps aux | grep "libre"
mohamed 54009 0.0 0.1 96096 4848 ? Sl 17:17 0:00 /usr/lib/libreoffice/program/oosplash --
writer
mohamed 54026 6.5 5.4 1111876 217036 ? Sl 17:17 0:02 /usr/lib/libreoffice/program/soffice.bin
--writer
mohamed 54044 0.0 0.0 9044 656 pts/0 R+ 17:18 0:00 grep --color=auto libre

su / sudo;
mohamed@mohamed-VM:~$ su
Password:

shutdown commands;
$ shutdown 2 Shuts down the system in two minutes.
$ shutdown -r 2 Reboots the system after two minutes.
$ shutdown -r now Reboots the system immediately.
$ shutdown -c or ctrl + C Cancels the shutdown commands

shutdown -r ;
mohamed@mohamed-VM:~$ sudo shutdown -r 2
[sudo] password for mohamed:
Shutdown scheduled for Thu 2022-10-06 11:51:20 +04, use 'shutdown -c' to cancel.
mohamed@mohamed-VM:~$ sudo shutdown -c
mohamed@mohamed-VM:~$

STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM


MOHAMED AHMED IBRAHIM
DUBAI - UAE

pwd / passwd;
$ pwd (print working Display the current working directory path.
directory)
$ passwd (password) Used to change the user account password.
$ passwd [username] To change the password for another account, not the one you
currently using.

pwd;
mohamed@mohamed-VM:~$ pwd
/home/mohamed

passwd;
mohamed@mohamed-VM:~$
passwd Changing password for
mohamed. Current password:
New password:
Retype new password:
Hint; Linux does display the password while you’re typing it, so be careful.

File management;
$ mv Rename the file ($ mv first.txt second.txt)
$ cp Copy the file content.
$ rm Delete a file.
$ mkdir Create a directory
$ touch To create a file.
$ chmod Change mode of a file system object
$ chmod a- Will prevent all use from writing on the file. All users has only read permission.
w
$ chmod To the right of execution for the user only.
u+x
$ chown To change the file’s ownership.

mv;
mohamed@mohamed-VM:~/Documents$ ls -l
total 12
-rw-rw-r-- 1 mohamed mohamed13 Oct 6 12:08 first.txt
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Music
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Videos

STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM


MOHAMED AHMED IBRAHIM
DUBAI - UAE

mohamed@mohamed-VM:~/Documents$ mv first.txt second.txt


mohamed@mohamed-VM:~/Documents$ ls -l total 12
drwxr-xr-x 2 mohamed mohamed 4096 Oct
-rw-rw-r-- 1 mohamed mohamed13 Oct 14:56 Music
12:08 second.txt
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Videos
mohamed@mohamed-VM:~/Documents$

cp;
mohamed@mohamed-VM:~/Documents$ cp second.txt third.txt
mohamed@mohamed-VM:~/Documents$ ls -l total 16
drwxr-xr-x 2 mohamed mohamed 4096 Oct
-rw-rw-r-- 1 mohamed mohamed13 Oct 14:56 Music
-rw-rw-r-- 1 mohamed mohamed13 Oct 12:08 second.txt
6 12:26 third.txt
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Videos
mohamed@mohamed-VM:~/Documents$

rm;
mohamed@mohamed-VM:~/Documents$ rm second.txt
mohamed@mohamed-VM:~/Documents$ ls -l total 12
drwxr-xr-x 2 mohamed mohamed 4096 Oct
-rw-rw-r-- 1 mohamed mohamed13 Oct 14:56 Music
12:26 third.txt
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Videos

Hint; “rm” allows you to remove only files or an empty directory, but if you need to delete an
entire directory with files in it you will need to use the “-r”.
mohamed@mohamed-VM:~$ rm Documents/
rm: cannot remove 'Documents/': Is a directory mohamed@mohamed-VM:~$ rm -r Documents/ mohamed@
total 32

drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Desktop


drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Downloads
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Music
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Pictures
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Public
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Templates
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Videos
mohamed@mohamed-VM:~$

mkdir;
mohamed@mohamed-VM:~/Documents$ mkdir note
STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM
MOHAMED AHMED IBRAHIM
DUBAI - UAE

mohamed@mohamed-VM:~/Documents$ ls -l
total 16
drwxr-xr-x 2 mohamed mohamed 4096 Oct 14:56 Music
drwxrwxr-x 2 mohamed mohamed 4096 Oct 6 12:45 note
-rw-rw-r-- 1 mohamed mohamed13 Oct 12:26 third.txt
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Videos

chmod;
Change mode of a file system object
 r=read, w=write, x=execute.
 Can also use octal notation.
 Set for the file owner (u), the group(g), others(o), or all(a).
Let’s edit the permissions on the folder “Note”
mohamed@mohamed-VM:~/Documents$ ls -l
total 16
drwxrwxr-x 2 mohamed mohamed 4096 Oct 6 12:45 note

The current permissions;


Owner (rwx) Group (rwx) Everyone (r-x)
7 7 5

# Permission r w x
7 Read, Write, and Execute r w x
6 Read and Write r w -
5 Read and Execute r - x
4 Read only r - -
3 Write and Execute - w x
2 Write only - w -
1 Execute only - - x
0 none - - -

To change these permissions, you need to use the numbers’ representation of permissions.
mohamed@mohamed-VM:~/Documents$ chmod 764 note
mohamed@mohamed-VM:~/Documents$ ls -l
total 16
drwxrw-r-- 2 mohamed mohamed 4096 Oct 6 12:45 note
mohamed@mohamed-VM:~/Documents$

This means;
STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM
MOHAMED AHMED IBRAHIM
DUBAI - UAE

 The owner has (Read, Write, and Execute).


 The group have (Read, and Write only).
 Everyone has (Read only).

chmod a-w;
mohamed@mohamed-VM:~/Documents$ chmod a-w third.txt
mohamed@mohamed-VM:~/Documents$ ls -l
total 16
-r--r--r-- 1 mohamed mohamed 13 Oct 6 12:26 third.txt

chmod u+x;
mohamed@mohamed-VM:~/Documents$ chmod u+x Script.sh
mohamed@mohamed-VM:~/Documents$ ls -l total 28
drwxrw-r-- 2 mohamed mohamed 4096 Oct
-rwxrw-r-- 1 mohamed mohamed 8341 Oct 6 12:45 note
6 13:23 Script.sh
-r--r--r-- 1 mohamed mohamed13 Oct 6 12:26 third.txt

chown [username:group] <filename>


mohamed@mohamed-VM:~/Documents$ sudo chown ahmed:mohamed Script.sh
[sudo] password for mohamed:***
mohamed@mohamed-VM:~/Documents$ ls -l
total 28
drwxr-xr-x 2 mohamed mohamed 4096 Oct 5 14:56 Music
drwxrw-r-- 2 mohamed mohamed 4096 Oct 6 12:45 note
-rwxrw-r-- 1 ahmed mohamed 8341 Oct 6 13:23 Script.sh
-r--r--r-- 1 mohamed mohamed 13 Oct 6 12:26 third.txt

Create files;
$ touch [filename.txt] Only creates the file, but don’t open it.
$ cat > [filename.txt] Creates the file and automatically give you access to edit it.
$ > [filename.txt] Only creates the file, but don’t open it.

cat > file.txt;


mohamed@mohamed-VM:~$ cat > file.txt
here we go, in here you can write what you want and then press (ctrl + D) to save the
file.
mohamed@mohamed-VM:~$

STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM


MOHAMED AHMED IBRAHIM
DUBAI - UAE

touch file.txt;
mohamed@mohamed-VM:~$ touch test1.txt
mohamed@mohamed-VM:~$ ls

Documents file.txt note Public test1.txt

> file.txt;
mohamed@mohamed-VM:~$ > test2.txt
mohamed@mohamed-VM:~$ ls

Documents file.txt note Public test1.txt test2.txt

ifconfig / iwconfig;
$ iwconfig Is used to view and configure the wireless network adaptors.
$ ifconfig Is used to view configure the wired network adaptors.
$ ip Some Linux distributions use “ip address” instead of
address “ifconfig”.

iwconfig
mohamed@mohamed-VM:~$ iwconfig
lo no wireless

ifconfig
mohamed@mohamed-VM:~$ iwconfig
Command 'ifconfig' not found, but can be installed with:

sudo apt install net-tools


mohamed@mohamed-VM:~$ sudo apt install net-tools

After install “ifconfig”;


mohamed@mohamed-VM:~$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.255.132 netmask 255.255.255.0 broadcast 192.168.255.255
inet6 fe80::7594:3f46:176e:a621 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:5f:06:ca txqueuelen 1000 (Ethernet)
RX packets 388793 bytes 547490594 (547.4 MB)
RX errors 582 dropped 25 overruns 0 frame 0
TX packets 128924 bytes 7119588 (7.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2000

STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM


MOHAMED AHMED IBRAHIM
DUBAI - UAE

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536


inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>

ip address
mohamed@mohamed-VM:~$ ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen
1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN
group default qlen 1000
link/ether 00:0c:29:5f:06:ca brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 192.168.255.132/24 brd 192.168.255.255 scope global dynamic noprefixroute
ens33
valid_lft 1325sec preferred_lft 1325sec
inet6 fe80::7594:3f46:176e:a621/64 scope link noprefixroute
valid_lft forever preferred_lft forever

apt-get; “Advanced Packaging Tool”


allows you to install, update, and remove applications and utilities.
mohamed@mohamed-VM:~$ sudo apt-get install wireshark

Process managing;
$ ps Display all the processes running by the current user.
$ ps -e | Display all the processes running on the system.
more
$ ps aux Display the Running process in a very detail view.

ps
mohamed@mohamed-VM:~$ ps
PID TTY TIME
CMD
50948 pts/0 00:00:00 bash

ps -e | more
mohamed@mohamed-VM:~$ ps -e | more
STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM
MOHAMED AHMED IBRAHIM
DUBAI - UAE

PID TTY TIME CMD


1 ? 00:00:17 systemd
2 ? 00:00:00 kthreadd
3 ? 00:00:00 rcu_gp
53130 ? 00:00:08 firefox
53177 ? 00:00:00 Socket Process
53193 ? 00:00 53338 pts/0 00:00:00 ps

pa aux
mohamed@mohamed-VM:~$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2 0.0 0.0 0 0 ? S 06:37 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 06:37 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 06:37 0:00 [rcu_par_gp]
root 18 0.0 0.0 0 0 ? S 06:37 0:00 [cpuhp/0]
systemd+ 47640 0.0 0.1 90908 6064 ? Ssl 09:37 0:00
/lib/systemd/systemd-timesyncd
root48139 0.0 0.2 314664 9268 ? Sl09:380:00 gdm-session-worker
[pam/gdm-password]
mohamed48147 0.0 0.2 19724 10440 ?Ss09:380:01
/lib/systemd/systemd --user
mohamed 48148 0.0 0.0 170536 3800 ? S 09:380:00 (sd-pam)
mohamed

Let’s kill the firefox processes;


Kill -l; is used to the parameters that can be used with “kill” command. The most used
parameters are 9, and 15.
mohamed@mohamed-VM:~$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ

We can use “pidof <process-name> to display the PIDs.


mohamed@mohamed-VM:~$ pidof firefox
53309 53304 53288 53238 53193 53177 53130

Then kill the process using (kill -parameter number [PID])


mohamed@mohamed-VM:~$ kill -15 53130

mohamed@mohamed-VM:~$ ps -e
{you’ll see nothing about firefox}
STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM
MOHAMED AHMED IBRAHIM
DUBAI - UAE

Or use “sudo killall [process-name]”


mohamed@mohamed-VM:~$ sudo killall firefox
[sudo] password for mohamed:

Visual mode editor;


vi [file] To view the file to edit.
Press “I” Allows you to write in the file.
Press “Esc” To exit the insert mode.
:wq To save the file and quit.
more [file] View the file’s content.

mohamed@mohamed-VM:~/Documents$ more first.txt


One of the best features of any Linux distribution is the advanced Command Terminal. Using
the Command Terminal, you can execute long and comp licated tasks by just writing a few
lines of commands that would otherwise require a long and complicated procedure on the
GUI. Although familiarizing yourself with the Terminal may seem daunting at first, it will
become your most valuable asset in your journey to master Ubuntu with time and practice.

mohamed@mohamed-VM:~/Documents$ vi first.txt

{this will open the file to be edited}

VI Editing commands:
 i – Insert at cursor (goes into insert mode)
 a – Write after cursor (goes into insert mode)
 A – Write at the end of line (goes into insert mode)
 ESC – Terminate insert mode
 u – Undo last change
 U – Undo all changes to the entire line

Open a new line (goes into insert mode)


 dd – Delete line
 3dd – Delete 3 lines.
 D – Delete contents of line after the cursor
 C – Delete contents of a line after the cursor and insert new text. Press ESC key to
end insertion.
STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM
MOHAMED AHMED IBRAHIM
DUBAI - UAE

 dw – Delete word
 4dw – Delete 4 words
 cw – Change word
 x – Delete character at the cursor
 r – Replace character
 R – Overwrite characters from cursor onward
 s – Substitute one character under cursor continue to insert
 S – Substitute entire line and begin to insert at the beginning of the line
 ~ – Change case of individual character

Moving within a file


 k – Move cursor up
 j – Move cursor down
 h – Move cursor left
 l – Move cursor right

STAY HUNGRY STAY FOOLISH MOHAMED AHMED IBRAHIM

You might also like