คำสั่งพื้นฐาน CentOS

คำสั่งพื้นฐาน CentOS ที่ถูกใช้งานบ่อยๆ

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]
  1. Fields [username] and [Comment] are self explanatory.
  2. 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].
  3. The [UID] and [GID] fields are integers that represent the User IDentification and the primary Group IDentification to which [username] belongs, respectively.
  4. The [Home directory] indicates the absolute path to [username]’s home directory, and
  5. 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]
  1. [Group name] is the name of group.
  2. An x in [Group password] indicates group passwords are not being used.
  3. [GID]: same as in /etc/passwd.
  4. [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:

  1. Execute the following command to discover the name of the installed package:
rpm -qa | grep Micro_Focus
  1. This returns PackageName, the RPM name of your Micro Focus product which is used to identify the install package.
  2. 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 ]


0
592