-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathBasic Linux Commands.txt
104 lines (98 loc) · 3.42 KB
/
Basic Linux Commands.txt
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
Linux Terminal Commands:
========================
netstat -tulpn | grep LISTEN - to check port in USE
ifconfig - to check the network interface (CentOS/RHEL5/6)
ip - CentOS/RHEL7
find /home/ubuntu/nodeapp/ -name "*.js" - Locate a file
chown - chown root lisa
chgrp - chgrp root lisa
chmod g-w jerry
man - get the manual of the commands
wc - word count
cp - copy a file to a new file
rm - remove or delete a file
mv - Move/Rename a file
mkdir - Create a directory
rmdir - Remove a directory
cat - List the content of a file
more - File Display Commands
less - File Display commands
head - File Display commands
tail - File Display Commands
cut - Filters
awk - Filters
grep - Filters
sort - Sort Files
uniq - List Unique content
wc - Word Count
diff - diff dc marvel (Line by Line)
cmp - cmp dc marvel (Byte by Byte)
tar - tar cvf file_name.tar
gzip
gzip -d
truncate - Shrink the size of a file (truncate -s 40 file_name) (File size will truncate to zero if given 0)
split - command to split Files
whoami - the current user
sed
useradd - Create a new user (cat /etc/shadow)
usermod - modify the current user (cat /etc/group) (usermod -aG Gopalakrishnan vijayam)
userdel - Delete a user (cat /etc/shadow)
groupadd - Create a Group
groupmod - Modify a Group
groupdel - Delete a Group
gpasswd --delete narayanan Colleagues
usermod -aG wheel awsmpadmin - add required local users to wheel group for sudo access
sed -i 's/^#\s*\(%wheel\s*ALL=(ALL)\s*NOPASSWD:\s*ALL\)/\1/' /etc/sudoers - Set Wheel group to sudoers with no password
su - username
who - Monitor users
id - Monitor users
users - Talk with Users
date - System Utility Commands
uptime - System Utility Commands
hostname - System Utility Commands
uname - System Utility Commands
which - System Utility Commands
systemctl - Start/Stop Processes
ps -aux | grep java - list running Processes
kill - Kill Processes
pkill - Process Kill
top - Tells about System Resources
crontab - Process Commands
at - Process Commands
bg - background Processes
fg - foreground Processess
df -h - Disk Partition (Human Readable form)
lsblk - Hard Disk Partition Tree
iostat 1 -
netstat -tupln | grep <java> -
shutdown - System Maintenance Commands
init 0-6 - System Maintenance Commands
reboot - System Maintenance Commands
halt - System Maintenance Commands
update-alternatives --config java
ln -s <symblink> <folder> - To create a symblink
unlink <symblink> - Remove symblink
du -sh server.log - Find the size of the logs
tar -zxvf test.tar.gz * - Extract the compressed file
tar -zxvf test.tar.gz * - Tar the Files
# zip older files
gzip log/server.log.* - Gzip an entire folder
# find files older than 7 days and delete the same
find log -name '*' -mtime +7 | xargs rm
/etc/profile - Stores user wide Environment variables. Loads user env variables on login
/etc/environment - System wide Environment Variables. Loads when the system boots up
chkconfig crond on - set crontab to run at boot
chmod 400 test/ - Locks down the folder. No one can access it
EXPORT - to export variables to env
unset - to remove variables to env
source /etc/profile - reload profile variables
/etc/ssh/sshd_config - sshd config
echo "centos" >> /etc/cron.allow - Adding CentOS user to run cron job
setfacl -Rdm u:centos:rwx /opt/websrvr/
env - List all the environment variables
# Create a new user with different home directory
mkdir -p /data/bigdata
cp -rT /etc/skel/ /data/bigdata
useradd bigdata
chmod -R bigdata:bigdata /data/bigdata
usermod -d /data/bigdata -m bigdata