คำสั่งพื้นฐาน CentOS
คำสั่งพื้นฐาน CentOS ที่ถูกใช้งานบ่อยๆ
2022-02-03 17:31:36 - @ratanon
File Management
แสดงไฟล์ที่อยู่ part นั้น
$ ls $ ls -R $ ll
ลบไฟล์
$ rm -r filename.xx $ rm -rvf folder
ย้ายไฟล์
$ mv home newfile $ mv workplace testfile1 Downloads
คัดลอกไฟล์
$ cp filename Directoryname $ cp testfile2 testfile3 Downloads
สร้างโฟลเดอร์
$ mkdir Samreenatasks
สร้างไฟล์
touch filename touch index.php
Create Symlinks – using ln command
$ ln -sf ~/bin/topprocs.sh topps.sh $ ls -l topps.sh
ให้สิทธิ์กับโฟลเดอร์
$ chmod 777 -R directory_name
ค้ณหาไฟล์
locate -i hello
Install Open File
apt-get
sudo apt-get [options] [command] sudo apt-get update sudo apt-get install vlc
User Management
Creating a new group
# groupadd common_group
Map group to user
usermod -aG common_group user1
Adding User Accounts
$ adduser [new_account] $ useradd [new_account]
Deleting a group
groupdel [group_name]
Check groups
$ groups
Removing user accounts */etc/passwd
$ userdel -r [username] $ userdel --remove [username] #แบบนี้จะลบสิทธิ์ที่เคยเพิ่มในไฟล์ต่างๆออกด้วย
Understanding */etc/passwd
[username]:[x]:[UID]:[GID]:[Comment]:[Home directory]:[Default shell]
- Fields [username] and [Comment] are self explanatory.
- The x in the second field indicates that the account is protected by a shadowed password (in /etc/shadow), which is needed to logon as [username].
- The [UID] and [GID] fields are integers that represent the User IDentification and the primary Group IDentification to which [username] belongs, respectively.
- The [Home directory] indicates the absolute path to [username]’s home directory, and
- The [Default shell] is the shell that will be made available to this user when he or she logins the system.
Understanding /etc/group
[Group name]:[Group password]:[GID]:[Group members]
- [Group name] is the name of group.
- An x in [Group password] indicates group passwords are not being used.
- [GID]: same as in /etc/passwd.
- [Group members]: a comma separated list of users who are members of [Group name].
Network
Check Port เครื่องปลายทาง
Single port:
$ nc -zv 127.0.0.1 80
Multiple ports:
$ nc -zv 127.0.0.1 22 80 8080
Range of ports:
$ nc -zv 127.0.0.1 20-30
nslookup
$ yum install bind-utils $ nslookup
list network services using netstat
sudo yum install net-tools netstat -pnltu netstat -pnltu | grep $port
- “-p” option shows all process IDs (PID) for sockets.
- “-n” option is used to list out the IP addresses.
- “-l” option prints the server socket having the “LISTEN” state.
- “-t” option is utilized to print the TCP connections.
- “-u” option is used to print the UDP connections.
ข้อมูลอ้างอิงจาก https://explainshell.com/
Uninstalling Using the RPM Installer
To uninstall a Micro Focus product:
- Execute the following command to discover the name of the installed package:
rpm -qa | grep Micro_Focus
- This returns PackageName, the RPM name of your Micro Focus product which is used to identify the install package.
- Execute the following command to uninstall the product:
rpm -e [ PackageName ]
Uninstalling several installation packages simultaneously
If you installed the same package more than once on the same machine using the --nodeps --prefix command line options, to remove all of these installations execute the following command:
[ as root ] rpm -e --allmatches [ package name ]