-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinux Commands Notes.txt
More file actions
145 lines (112 loc) · 6.08 KB
/
Linux Commands Notes.txt
File metadata and controls
145 lines (112 loc) · 6.08 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
Fields/Column Description
PID Process Id
USER The effective user name of the task's owner
PR The priority of the task
NI The nice value of the task. A negative nice value means higher priority
VIRT The total amount of virtual memory used by the task
not be adjusted in determining a task's dispatchability
RES The non-swapped physical memory a task has used
S 'D' = uninterruptible sleep
'R' = running
'S' = sleeping
'T' = traced or stopped
'Z' = zombie
SHR The amount of shared memory used by a task
%CPU The task's share of the elapsed CPU time since the last screen update, expressed as a
percentage of total CPU time.
%MEM A task's currently used share of available physical memory
TIME+ Total CPU time the task has used since it started
Command Display the command line used to start a task or the name of the associated program
%Cpu Value Meaning
****************************
us user cpu time (or) % CPU time spent in user space
sy system cpu time (or) % CPU time spent in kernel space
ni user nice cpu time (or) % CPU time spent on low priority processes
id idle cpu time (or) % CPU time spent idle
wa io wait cpu time (or) % CPU time spent in wait (on disk)
hi hardware irq (or) % CPU time spent servicing/handling hardware interrupts
si software irq (or) % CPU time spent servicing/handling software interrupts
st steal time - - % CPU time in involuntary wait by virtual cpu while hypervisor is servicing
another processor (or) % CPU time stolen from a virtual machine
Arguments in Top Command
*************************************
press 'u' - Particular user process listout
press 'M' - Memory high to low usage
press 'P" - CPU high to low usage
press 'r' - Change nice value - default top PID or choose
press 'k' - Kill process - default top PID or choose
press 'd' - Change refresh time - default 3 sec
press 'n' - Choose No of task will be display
press '1' - All the individual CPUs report
press 'f' - list of available fields under top command- add new fields / remove fields
Using awk command to list all users in Ubuntu
By using awk command we can get just the first field from the /etc/passwd file. Awk is a powerful text manipulation tool in Linux.
$ awk -F: '{ print $1}' /etc/passwd
Creating a new user
Apart from knowing how to list all users in Ubuntu, it is important also to know how to add a new user. To create a new user in Linux, use the following command:
$ useradd username
This will create a new entry in the /etc/passwd file
Get information about a particular user
You can use grep command to get information about a particular user from the /etc/passwd file. This is useful if there are a lot of users in the /etc/passwd file. This can help in checking for the existence of a particular user.
$ grep username /etc/passwd
Grep Username
We get information about a user named Adam from the /etc/passwd file.
sample shell script command
How to Write Shell Script in Linux/Unix
Shell Scripts are written using text editors. On your Linux system, open a text editor program, open a new file to begin typing a shell script or shell programming, then give the shell permission to execute your shell script and put your script at the location from where the shell can find it.
Let us understand the steps in creating a Shell Script:
Create a file using a vi editor(or any other editor). Name script file with extension .sh
Start the script with #! /bin/sh
Write some code.
Save the script file as filename.sh
For executing the script type bash filename.sh
“#!” is an operator called shebang which directs the script to the interpreter location. So, if we use”#! /bin/sh” the script gets directed to the bourne-shell.
Let’s create a small script –
#!/bin/sh
#Sample 1
ls
#!/bin/sh
#Sample 2
echo "what is your name?"
read name
echo "How do you do, $name?"
read remark
echo "I am $remark too!"
ps -ef | grep sshd to check SSH is running
Password settings change for EC2 Intances
cd /etc/ssh/ Go to this path
vi sshd_config is the file comend password and enable the setting
/etc/ssh are directories
systemctl restart sshd to restart sshd if we make any changes on authentication
C:\Users\Navaneethan C is the home directory in windows
cat /etc/passwd|grep root to know the directory of the user grep username you looking for
to view users
cd /etc/
the cat passwd to view list of users
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
libstoragemgmt:x:999:997:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
rngd:x:998:996:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
ec2-instance-connect:x:997:995::/home/ec2-instance-connect:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:996:994::/var/lib/chrony:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
ec2-user:x:1000:1000:EC2 Default User:/home/ec2-user:/bin/bash
Linux curl command is used to download or upload data to a server via supported protocols such as HTTP, FTP, IMAP, SFTP, TFTP, IMAP, POP3, SCP, etc. It is a remote utility, so it works without user interaction. The data transfer from one place to another is one of the vital and most used tasks of a computer system.