Các Lệnh Cơ bản trong CentOS 6 – phần 2

1. yum-tùy chon update

cú pháp yum <option command package>

install Install a package or packages on your system

# yum install package
update Update a package or packages on your system

# yum update package
remove Remove the packages

# yum remove package
groupinstall Install the packages in a group on your system

# yum groupinstall “X Window System”
groupupdate Update the packages in a group on your system

# yum groupupdate “X Window System”
groupremove Remove the packages in a group from your system

# yum groupremove “X Window System”
list List a package or groups of packages

# yum list
⇒ display packages that is possible to install
# yum list installed
⇒ display installed packages
check-update Check for available package updates

# yum check-update
info Display details about a package or group of packages

# yum info package
search Search package details for the given string

# yum search keyword
deplist List a package’s dependencies

# yum deplist package
-y answer yes for all questions

# yum -y install package
–enablerepo=repo enable one or more repositories (wildcards allowed)

# yum –enablerepo=repo install package
–disablerepo=repo disable one or more repositories (wildcards allowed)

# yum –disablerepo=repo install package
–exclude=package exclude package(s) by name or glob

# yum –exclude=package update
–noplugins disable Yum plugins

# yum –noplugins update


2.wget – The non-interactive network downloader


-c resume getting a partially-downloaded file

3.rpm –  quản lý Package RPM

[Cú pháp ] rpm <OPTION PACKAGE>
-i This installs a new package

# rpm -i package
-F This will upgrade packages, but only if an earlier version currently exists

# rpm -F package
-U This upgrades or installs the package currently installed to a newer version

# rpm -U package
-e erase (uninstall) package

# rpm -e package
-q query packages

# rpm -q package
-V verify installed packages

# rpm -V package
-K verify package signature

# rpm -K package
–rebuilddb rebuild the database indices from the installed package headers

# rpm –rebuilddb
–initdb create a new database if one doesn’t already exist

# rpm –initdb
–import import PUBKEY

# rpm –import /usr/share/rhn/RPM-GPG-KEY
options with i, U
-v show package name

# rpm -iv package
-h display progress

# rpm -ivh package
-vv Print lots of ugly debugging information

# rpm -ivv package
–nodeps Don’t do a dependency check before installing or upgrading a package

# rpm -ivh –nodeps package
–test Don’t really uninstall anything, just go through the motions

# rpm -ivh –test package
options with q
-a Query all installed packages

# rpm -qa
-i Display package information, including name, version, and description. This uses the –queryformat if one was specified

# rpm -qi package
-l List files in package

# rpm -ql package
-c List only configuration files (implies -l)

# rpm -qc package
-d List only documentation files (implies -l)

# rpm -qd package
-f Query package owning FILE

# rpm -qf /bin/bash
-R List packages on which this package depends

# rpm -qR package
-s Display the states of files in the package (implies -l)

# rpm -qs package
–last Orders the package listing by install time such that the latest packages are at the top

# rpm -q –last package
–changelog Display change information for the package

# rpm -q –changelog package




Đọc và thực hiện lệnh từ tên file trong cửa sổ lệnh hiện tại ,trả về trạng thái sau khi đã thực hiện lệnh

5.visudo – chỉnh sửa sudoers file

[cú pháp] visudo OPTION
-c Enable check-only mode
-f FILE Specify and alternate sudoers file location
-q Enable quiet mode
-s Enable strict checking of the sudoers file

6.shutdown -tắt hệ thống

[cú pháp] shutdown OPTION TIME MESSAGE
-h Halt or poweroff after shutdown

# shutdown -h now
-r Reboot after shutdown

# shutdown -r +10
-f Skip fsck on reboot

# shutdown -rf +20 “This System will shutdown soon”
-k Don’t really shutdown; only send the warning messages to everybody

# shutdown -k now
-c Cancel an already running shutdown

# shutdown -c

7.sudo – sudoedit – execute a command as another user

-u USER causes sudo to run the specified command as a user other than root
-s runs the shell specified by the SHELL environment variable if it is set or the shell as specified in passwd(5)
-H sets the HOME environment variable to the homedir of the target user (root by default) as specified in passwd(5)
-l The -l (list) option will list out the allowed (and forbidden) commands for the invoking user on the current host
-h show help
-v sudo will update the user’s timestamp, prompting for the user’s password if necessary
-k The option to sudo invalidates the user’s timestamp by setting the time on it to the Epoch
-K The option is like -k except that it removes the user’s timestamp entirely
-b The option tells sudo to run the given command in the background

8.userdel – xóa user account hoặc file liên quan

[cú pháp] userdel OPTION USER
-r remove home directory and mail spool