Basic command Flashcards

1
Q

CTRL+D == exit

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

man ‘command’

A

command manual
@6 jeld darad
** bazi dastoorat dar chand jeld hastand
man 5 passwd => mige az jeld 5 baraam bekhon

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

env

A

print envirenment variable

USER = The name of the logged-in user

PATH = List of directories to search for commands, colon separated

EDITOR = Default editor

HISTFILE = Where bash should save its history (normally .bash_history)

HOSTNAME = System hostname

PS1 = The Prompt! Play with it

UID = The numeric user id of the logged-in user

HOME = The user’s home directory

PWD = The current working directory

SHELL = The name of the shell

$ = The process id (or PID of the running bash shell (or other) process

PPID = The process id of the process that started this process (that is, the id of the parent process)

? = The exit code of the last command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

if we want to print or use this character without interpretation we have to ?
* ?[]’”$;&()|^<>

A

quote them or use with \

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

echo -e “hello\nhello\thello\v”

A

@-e chizi ke baad az \ miaad ro tafsir mikone

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

mhdadizadeh=’mohamad\ hadi\ dadizadeh’
echo $mhdadizadeh

A

define envirenment var and print by echo
**space to bayad ba \ scape kard
**dastoor aval bayad bedoon fasele bashe
**var moghe echo baayad $ dashte baashe

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

export mhdadizadeh=hadi

A

@dar hame level ha taarif mishe

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what happen when enter a command?

A

first : check if is a builtin command then execute
second : @file ha ee ka dar $PATH adderess dadim be tartib check mikone va age onja ham chizi peyda nakard error mide

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

PATH=$PATH:/home/mhdadizadeh/bin

A

add path to $PATH

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

@linux current dir ro ham baraye ejraye barname ha check mikone? why?

A

@na , be dalayel amniati

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

which ‘command’

A

@age in command ro bezanam chi run mishe?

The which command searches through the directories that are defined in the $PATH environment variable for a given filename.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

unset env_var

A

unset envirenment variable

-v : unset shell var if exist
-f : unset shell func if exist

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

$HISTFILE Vs history

A

$HISTFILE : baad az exit command ha tooch save mishan
history : yek shell builtin command ast va dastorat haman moghe zakhire mishavan

Ctrl+R = Backward Search
Ctrl+O = Run the command you found with Ctrl+R
!! = Run the last command
!10 = Run command number 10 of history
!text = search backward for text, and run the first found command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

whereis ‘command’

A

@khodesh va mokhallafatesh koja hastan
**baazi dastoorat chand ja hastan ya maani haye motafaveti daaran

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

whatis ‘command’

A

print first line of discription

** age chand ta tafsir dasht hamasho mide

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

type ‘command’

A

@yek command ro midi behesh va mige chetor tafsir mishe

**mamolan path file ejraee ro mide

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

cd /home/mhdadizadeh

A

Absolute Paths
** / means root dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

cd dir1/dir2/dir3

A

Relative Paths

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

cd
cd ~
cd $HOME

A

home dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

cd ~[username]

A

goes to another user’s home directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

cd ..

A

moves one directory up.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

cd -

A

moves to your previous directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

uname -a

A

Gives you data about the system

-s = Print the kernel name. This is the default if no option is specified.
-n = Print the nodename or hostname.
-r = Print the release of the kernel.
-m = Print the machine’s hardware (CPU) name.
-o = Print the operating system name.
-a = hameche ba ham

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

ls -R

A

lists all the files in the subdirectories

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

ls -a

A

shows hidden files in addition to the visible ones

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

ls -lh

A

shows the file sizes in easily readable formats, such as MB, GB, and TB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

ls -ltrh

A

l : long detail
t : sort by time
r : reverse sort
h : human readable

** -S : sort by time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

cp file dir

A

copy file to dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

cp file1 file2

A

copy file to another file
@age nabood misaze
@age bood, overwrite

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

cp file1 file2 file3 dir

A

@chand ta file ro beriz to ye dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

cp -R dir1 dir2

A

@copye ye dir va cole mohtaviatesh to ye dir dige

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

cp -b file1 file2

A

-b : (–backup) will make backups of overwritten files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

cp -p file1 file2

A

-p : will preserve the attributes.

** moshakhasat file aval ro ham nigiri

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

cat file1 file2 file3

A

@file haye voroodi ro migire concat mikone va namayesh mide

** cat -n file1 : shomare khat mizane

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

bzcat, xzcat, zcat, gzcat

A

These let you see the contents of compressed files without uncompressing them first

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

cat file1 file2 > dir/file3

A

@chand ta file ro yeki kon beriz to ye filee dige

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

less file
or
cat file | less

A

q = Exit
/foo = Searches for foo
n = Next (search)
N = Previous (search)
?foo = Search backward for foo
G = Go to end
nG = Go to line n
PageUp, PageDown, UpArrow, DownArrow = You guess!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

od file

A

(Shows files in formats other than text). Normal behavior is OctalDump (showing in base 8)

-t will tell what format to print:
-t a for showing only named characters
-t c for showing escaped chars.
You can summarize the two above to -a and -c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

mv file1 file_name

A

rename file to another name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

mv file1 dir

A

move file to another place

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

mv Vs cp

A

@mv file ro as maghsad pak mikone

@cp file ro as maghsad pak nemikone

@har do dar har sorat ya file ro misazan ya overwrite mikonan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

mkdir dir_name

A

@saakht dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

mkdir dir/dir/dir_name

A

@saakhte dir dar yek dir dige
**parent dir bayad mojood bashe

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

mkdir -p dir1/dir2/dir3

A

@saakhte hamzaman dir va parent hash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

mkdir -m777 dir/dir/dir_name

A

@saakhte file hamraah bo dadan permissio

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

mkdir -v file1

A

prints a message for each created directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

switch: -v

A

@harf bezan begoo dare chi mishe

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

switch: -r

A

@baazgashti amal kon

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

rmdir dir

A

delete empty dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

rmdir -p dir1/dir2/dir3

A

@khodesh va hame ajdadesho paak kon
** agar khaali boodan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

rm file1 file2 file3

A

remove files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

rm -i

A

@ghabl as pak kardan soal dkon

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

rm -f

A

@bedoon soal har chi didi pak kon

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

rm -r

A

@be soorat baazgashti boro toye pooshe ha va hame file ha ro pak kon

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

touch file1

A

create new file or change time of creation of exist file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

touch -t [timestamp] file1

A

specify time of file by timestamp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

touch -d [unix_time] file1

A

specify time of file with unix base time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

$ touch -t 200908121510.59 file1
$ touch -d 11am file2
$ touch -d “last fortnight” file3
$ touch -d “yesterday 6am” file4
$ touch -d “2 days ago 12:00” file5
$ touch -d “tomorrow 02:00” file6
$ touch -d “5 Nov” file3

A

specify creation time of file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

touch -r refrens_file file1

A

specify file creation file by referencing to another file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

split -n 2 file1

A

split file into pieces

-n = split file by number of pieces
-l = split file by number of line
-b = split file by number of bytes

-d = use numeric suffix start from 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

cut -f1 -d, file1

A

cut one or more columns from a file
-f = selected columns 1,3,4 or range 1-3
-d = delimiter (only one character)

** default delimiter is TAB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

nl == cat -n

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q

sort file1

A

-r : reverse sort
-n : sort numerically
-d : ignore blankes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
64
Q

uniq file1

A

** the input most be sorted file
-c = count of each item
-u = show only non-repeated item
-d = show only repeated item

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

find ./ -type f

_______
-type d
-type l

A

@to in directory hame file ha ya dir ha ya link ha ro peyda k

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
66
Q

find ./ -iname “file_name”

A

@to in dir har chi ba in name hast to bedo
**iname case sensitive nist

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
67
Q

find . -iname ‘*.png’ -type f -size -100k

A

finish with .png
with type file
with size less than 100k

68
Q

find . -type f -mmin -30

A

mmin : Modified Minutes
cmin : Status Change Min
amin :‌ Access Minutes

** -ls az file ha ls migire
-delete file ya dir haye peyda shode ro pak mikone

69
Q

find ~ -type f -mmin -1 -exec wc -l ‘{}’ \;

A

@-exec aakhar find miad va ye command roye natayej ejra mikone

70
Q

grep

A

for search by regex in file or stdin

71
Q

grep ‘text’ file1

A

search text in file

72
Q
  1. du command
A
73
Q

head file1

A

print first 10 lines of file

-n :‌ count of line you want to display
-c : count of byte you want to display
-q or –quiet : will not print headers specifying the file name.

74
Q

head -n 5 file1

A

print first 5 line of file

75
Q

tail file1

A

print last 10 line of file

-n :‌ count of line you want to display
-c : count of byte you want to display
-q or –quiet : will not print headers specifying the file name.

76
Q

tail -n 5 file1

A

print last 5 line of file

77
Q

tail -f file1

A

follow end of the file and if new data added then display

78
Q

cat file | tr ‘123’ ‘۱۲۳’
or
echo 123 | tr ‘123’ ‘abc’

A

@ mitoone yek majmooee character ro ba ye mahmooee dige jaa be jaa kone
** pure filter ast va input nmigirad

79
Q

sed s/hadi/mohamad/g file

A

sed is stream editor

Sed is a great tool for replacing text with using regular expressions

replace hadi with mohamad all over the file

80
Q

wc file1

A

word count

-l = line
-w = word
-c = bytes

81
Q

wc -l file | cat file - file
echo “bar” |cat file - file

A

the output of previos step replace with -

82
Q

tell me three hashing function ?

A

@yek input ba size delkhah migire yek outup uniqe ba size yeksan mide

md5sum
sha256sum
sha512sum

** mishe chand ta file dad va hash hamashono zire ham did

83
Q

Wildcards:‌ *

A

means any string

84
Q

Wildcards:‌ ?

A

means any single character

85
Q

Wildcards:‌ [ABC]

A

matches A, B, or C

86
Q

Wildcards:‌ [a-k]

A

matches a, b, c, …, k (both lower-case and upper-case)

87
Q

Wildcards:‌ [0-9a-z]

A

matches all digits and numbers

88
Q

Wildcards:‌ [!x]

A

means NOT X

89
Q
  1. diff command
A
90
Q

gzip file1

gunzip file1

A
91
Q

bzip2 file1

bunzip2 file1

A
92
Q

xz file1

unxz file1

A
93
Q

xz file1 -k

A

-k = keep the original file when create compress file

94
Q

zip [file_name.zip] file1 file2 …

unzip file.zip

A
95
Q

tar -cvf file.tar [file or dir] [file or dir] [file or dir]

A

@archive kardan file ha dar file.tar

-c : create
-f : file
-v : verbus

96
Q

tar xf file.tar–directory ~/dir

A

extract tar file to differant dir
-x : extract
-f : file

97
Q

tar -xf file.tar

A

extract tar file
-x : extract
-f : file

98
Q

tar xfz 2file.tar.gz

A

** first decompres from zip then extract from tar

99
Q

tar tf file.tar

A

-f : file name
-t : lists the content of a file

100
Q

tar uf file.tar file3

A

-u :‌ archives and adds to an existing archive file.

101
Q

tar

A

x : Extract files

f : Tar archive name

–directory : Set directory name to extract files

-C : Set dir name to extract files

-z : Work on .tar.gz (gzip) file format

-j : Work on .tar.bz2 (bzip2) file format

-J (capital J) : Work on .tar.xz (xz) file format

-v : Verbose output i.e. show progress on screen

102
Q
  1. chmod command
A
103
Q
  1. chown command
A
104
Q

touch -r [refrens file] file1

A

specify file creation file by refensing to another file

105
Q

file file_name

A

@formate file ro mide

106
Q

file -i filename

A

@mime type ro mide

107
Q

dd if=file1 of=file2 count=2 bs=4096

A

@block size ro migire va be tedad count as file1 mirize too file2

108
Q

dd if=file | gzip > file.dd.gzip

A

copy and zip the file

109
Q

@linux current dir ro ham baraye ejraye barname ha check mikone? why?

A

@na , be dalayel amniati

110
Q

tell me number of the term bellow:
stdin?
stdout?
stderr?

A

stdin : 0
stdout : 1
stderr : 2

111
Q

ls > file

A

Redirect STDOUT to a file; Overwrite if exists

112
Q

tree&raquo_space; file

A

Redirect STDOUT to a file; Append if exists

113
Q

ls undefine.txt file.txt&raquo_space;stdout.txt 2»stderr.txt

A

@it’s clear?

114
Q

command 2> file

A

Redirect STDERR to a file; Overwrite if exists

115
Q

command 2» file

A

Redirect STDERR to a file; Append if exists

116
Q

command &> file

A

Redirect both STDOUT and STDERR; Overwrite if exists

117
Q

command &» file

A

Redirect both STDOUT and STDERR; Append if exists

118
Q

tr ‘۱۲۳’ ‘123’ < file.txt

A

@file hadi be onvan stdin be tr dade mishe

119
Q

command >log.txt 2>&1

A

@stderr ro ham beriz hamon ja ke stdout ro rikhti

&0 :‌ hamon ja ke stdin
&1 : hamon ja ke stdout
&2 : hamon ja ke stderr

120
Q

ls 2>&1 >file1

A

@ stderr ro beriz hamon ja ke stdout ro mirizi , hala std out ro beriz to file1 , yanii hamashon to file1

121
Q

ls j* x* >file1 2>/dev/null

A

stdout to file1
stderr ro beriz door
** /dev/null == aashghali

122
Q

cat &laquo_space;END > file

A

create and write file at the same time

123
Q

command1 | command2

A

stdout of command1 == stdin of command2

124
Q

question?
bishtarin distribution linux be tartib tedad (ba pipe)

A
125
Q

echo hadi | xargs -I variable cat variable

A

@roo khorooji dastor ghabl ye command run mikone

** -I : variable misaze

126
Q

echo text | tee -a file

A

append text to file also write in stdout

**without -a , text will be overwriten

127
Q

[process or program] &

A

start and send the process to background

128
Q

when process is running:

Ctrl+c ?
Ctrl+z ?

A

Ctrl + c : break
Ctrl + z : suspend

129
Q

jobs

A

list all the jobs

-l : lists process IDs along with their information.
-n : lists jobs whose statuses have changed since the last notification.
-p : lists process IDs only.

130
Q

bg %[process_number]

A

send a process to background

131
Q

fg %[process_number]

A

send the process to foreground

132
Q

jobs -l

A

list all the jobs + process id

133
Q

nohup ping google.com

A

The nohup command lets you run your commands even after you close the terminal or logout. By default it writes its output to nohup.out

134
Q

ping google.com &>~/logs &

A

send output and error to logs and send process to background

135
Q

ping [option] [hostname_or_IP_address]

A

send ICMP ECHO_REQUEST to network hosts

136
Q

kill -SIGNAL_ID_OR_NAME process_id

A

signal id and name:
1 = HUP = Informing the process that its controlling terminal (like an ssh connection) is terminated
15 = TERM = normal termination request
9 = KILL = forcefully kills the process

SIGTERM requests a program to stop running and gives it some time to save all of its progress. The system will use this by default if you don’t specify the signal when entering the kill command.
SIGKILL forces programs to stop, and you will lose unsaved progress.

Remember the nohup command ? :) It means “ do not respond to the hup signal “.

137
Q

killall process_name

A

This command Will send the given signal (or by default 15) to all processes with the given name

138
Q

pkill *ping

A

Will send the given signal (or 15) to all the processes with a specific pattern in their name

139
Q

ps -ef

A

show all the process on a system
-e == -A : all process
-f == full format

140
Q

ps -u

A

show all the process on the system

-a = -e = all
-u = user

141
Q

ps -aux Vs ps -ef

A
142
Q

??? => ps -af –sort +comm,-sid

A

sort process by key

143
Q

pgrep ‘text’

A

pgrep ‘text’ == ps -ef| grep ‘text’

144
Q

top

A

-display Linux processes
simple monitoring of the system
You can see the processes, system load, uptime, CPU status, memory, … and do some stuff.

The top command can also help you identify and terminate a process that may use too many system resources.

h = help
q = quit
M = sort based on memory usage”
c = show full commands
k = kill after asking pid and signal

145
Q

free

A

The free command will show you info about the system memory
-m = for megabytes
-g = for gigabytes or even
-b = for bytes
-h = for human readable

146
Q

uptime

A

command shows the time, systems uptime (how long the system has been running), how many users are logged in, and the load average of 1, 5 & 15 minutes

Although it’s one of the most important KPIs of the system status, some of the experienced Linux admins do not know what the load average means. The load average shows how many processes are in the to be run queue. If this number is higher than the number of your CPU cores, you are in a bad situation. If it’s close to the number of your cores constantly, it’s kind of dangerous, and if it’s less than 1/10th of your core numbers, your system is kind of idle. Do you remember how to check the number of your cores? Its in /proc/cpuinfo or nproc.

147
Q

watch ‘command’

A

It lets you run and check the output of a command in specific time intervals (default is 2 seconds).

-n =To specify the interval in seconds
-b = Beep if the command has a non-zero exit
-d = Shows the difference between runs

148
Q

sudo ‘command’

A

lets you perform tasks that require administrative or root permissions.

149
Q

tac file1

A

displays content in reverse order

150
Q

locate file_name

A

locate is a Unix utility which serves to find files on filesystems. It searches through a prebuilt local database of all files on the filesystem generated by the updatedb command.

Note it is essential to update the database as recent files saved over a period of fewer than 24 hours are not updated into the database by default and the database is updated once within 24 hours span.

** age donbal file ha ee hasti ke kamter az 24 saat ghabl dorost shoden. ‘updatedb’ bezan

151
Q

df -h

A

report file system space usage

-h : human readable

152
Q

du -sh dir

A

estimate file space usage

-s : totla
-h :‌human readable (GB)
-m :‌ size in MB
-l : size in KB

153
Q

diff -c file1 file2

A

compare files line by line

-c : displays the difference between two files in a context form.
-u :‌ displays the output without redundant information.
-i : makes the diff command case insensitive.

154
Q

tar tf file.tar

A

-f : file name
-t : lists the content of a file

155
Q

ls -l file1:

-rw-r–r–. 1 mhdadizadeh mhdadizadeh 0 Jan 4 16:00 file1

A

1 ( - / d ) : file or dir
2 ( rwx ) : owner’s permissions
3 ( rwx ) : group’s permissions
4 ( rwx ) : others’ permissions

1 : the number of hard links. A hard link is an additional name for an existing file
mhdadizadeh mhdadizadeh : the owner and group owner of the file.
0 : the size of the file in bytes
Jan 4 16:00 : the last modification date
file1 : the name of the file/folder

156
Q

tell me number of each permition :

r (read) :
w (write) :
x (execute) :

tell me permition of this number:

3 :
5 :
6 :
7 :

A

r (read) : 4
w (write) : 2
x (execute) : 1

3 : execute - write
5 : read - execute
6 : read - write
7 : read - write - execute

** owner - group - other

** If you don’t want to give any permission to a user, enter 0 into the corresponding spot.

157
Q

chmod 777 [file or dir]

A

@dadan hame permissions ha be hame user ha

158
Q

chown user_1 file1

A

The chown command lets you change the ownership of a file, directory, or symbolic link to a specified username.

**chown [option] owner[:group] file(s)

? : har file yek owner va yek group darad?
? : mishe owner va group kamelan az ham part bashan?

159
Q

&&&‌ cut -d: -f1 /etc/passwd

A

username of the system user

160
Q

&&& wget [option] [url]

A

The non-interactive network downloader

161
Q

hostname == uname -n

A

Run the hostname command to know the system’s hostname

162
Q

&&& useradd

A

create a new user or update default new user information

163
Q

alias rm=’echo “boro in daam bar morghi degar neh”’

unalias [rm]

A

alias allows you to create a shortcut with the same functionality as a command

164
Q

&&& su [options] [username [argument]]

A

The switch user or su command allows you to run a program as a different user

-p or –preserve-environment keeps the same shell environment, consisting HOME, SHELL, USER, and LOGNAME.
-s or –shell lets you specify a different shell environment to run.
-l or –login runs a login script to switch to a different username. Executing it requires you to enter the user’s password.

165
Q

ps

ps -u mhdadizadeh

A

@ye snapshot as process haye feeli mide

process ID (PID)
type of terminal (TTY)
running time (TIME)
command that launches the process (CMD)

switches:

-T : displays all processes associated with the current shell session.

-u username : lists processes associated with a specific user.

-A or -e shows all the running processes.