1、hardinfo
查看計算機硬件信息(Ununtu下適用,Redhat不適用)
若未安裝,鍵入一下命令完成安裝
sudo apt-get install hardinfo
2、kill
殺死進程
# ps -A(顯示當前運行的進程)
# kill pid(pid爲ps -A顯示的進程ID)
# kill -9 pid(強制殺死某個進程)
3、rm
刪除文件及文件夾
# rm -rf dir
強制性、忽略提示的刪除
4、修改主機名
- 使用 hostname 修改當前主機名。
# hostname new-hostname - 修改 /etc/sysconfig/network 配置文件,以便下次重啓的時,使用新的主機名。
打開 /etc/sysconfig/network 文件,修改 HOSTNAME=new-hostname.domainname。
修改後的 /etc/sysconfig/network 文件如下:
NETWORKING=yes
HOSTNAME=new-hostname.localdomain - 修改本機的域名解析文件 /etc/hosts ,使得本機的應用程序能夠解析新的主機名。
編輯文件: /etc/hosts
修改: xxx.xxx.xxx.xxx new-hostname.domainname new-hostname
(這裏的xxx代表本機的網絡地址,也可以是環回地址127.0.0.1) - 修改後的 /etc/hosts 文件如下:
127.0.0.1 localhost.localdomain localhost
127.0.0.1 new-hostname.localdomain new-hostname - reboot查看主機名是否修改成功
5、ln
它的功能是爲某一個文件在另外一個位置建立一個同不的鏈接,這個命令最常用的參數是-s,具體用法是:ln -s 源文件 目標文件。
注意:
第一,ln命令會保持每一處鏈接文件的同步性,也就是說,不論你改動了哪一處,其它的文件都會發生相同的變化;
第二,ln的鏈接又軟鏈接和硬鏈接兩種,軟鏈接就是ln -s ** **,它只會在你選定的位置上生成一個文件的鏡像,不會佔用磁盤空間,硬鏈接ln ** **,沒有參數-s, 它會在你選定的位置上生成一個和源文件大小相同的文件,無論是軟鏈接還是硬鏈接,文件都保持同步變化。軟鏈接是可以跨分區的,但是硬鏈接只能在同一分區內。
如果你用ls察看一個目錄時,發現有的文件後面有一個@的符號,那就是一個用ln命令生成的文件,用ls -l命令去察看,就可以看到顯示的link的路徑了。
6、添加用戶到sudo組:
切換到超級管理員su
修改配置文件:visudo(注意vi與sudo之間沒有空格,直接輸入這個命令相當於編輯/etc/sudoers這個文件)
找到root ALL=(ALL) ALL這一行,在下一行添加XXX ALL=(ALL) ALL這一行(XXX即你想要添加到sudo組的用戶名)。
保存,退出。這樣就成功添加XXX的sudo權限了。
7、chown、chgrp
更改文件的所有者與組別
更改所有者:chown uers 文件名
更改組別:chgrp 組別 文件名
8、rpm
利用rpm查看安裝包
# rpm -ql packagename
# rpm -qi packagenane
</pre><p></p><h1>9、date</h1><p>修改系統時間</p><p></p><pre name="code" class="html"># date -s 2012-7-30
# date -s 15:36:00
# hwclock -w(將系統時間同步到硬件)
# hwclock --systohc
# hwclock --hctosys
10、find
# find / ifcfg-eth0
# find / ifcfg-eth0 -ls
# find /opt/netiq/cloudmanager/ catalina
11、修改postgres密碼
# sudo su postgres
# psql postgres
# alter user postgres with password 'new password'
12、tar
# tar -zcvf huboss/ huboss.tar.gz
# tar-zxvf huboss.tar.gz -C /home/huboss
壓縮
# tar -jcvf huboss/ huboss.tar.bz2
解壓
# tar -jxvf huboss.tar.bz2 /home/huboss
13、HBA卡信息查詢
/sys/class/fc_host/hostx/port_name 或node_name HBA卡的WWN號。
symbolic_name HBA卡型號
speed HBA卡速度
port_state HBA卡狀態
spupported_speed HBA卡支持的速度
14、/etc/host.conf
order hosts,bind /*定義解析主機名的順序,hosts-主機hosts文件,bind-DNS*/
mutli on /*on 表示允許hosts中主機有多個IP地址*/
15、TTY
輸出當前設備終端的名稱
[root@rhel6 ~]# tty
/dev/tty1 /*此設備爲虛擬終端設備,按CTRL+ALT[F1-F6]等可進入對應的tty*/
[root@rhel6 ~]# tty
/dev/pts/0 /*利用ssh連接的終端*/
<p>PS</p># echo "hello" >> /dev/tty1 /*可將信息“hello”傳送至tty1終端*/
# who /*可顯示當前的用戶與終端的對應關係*/
15、ovs-vsctl
create a new bridge named br0 and add port eth0 to it:
# ovs−vsctl add−br br0
# ovs−vsctl add−port br0 eth0
Alternatively, perform both operations in a single atomic transaction:
# ovs−vsctl add−br br0 −− add−port br0 eth0
Delete bridge br0, reporting an error if it does not exist:
# ovs−vsctl del−br br0
Delete bridge br0 if it exists:
# ovs−vsctl −−if−exists del−br br0
Set the qos column of the Port record for eth0 to point to a new QoS record, which in turn points with its queue 0 to a new Queue record:
# ovs−vsctl −− set port eth0 qos=@newqos −− −−id=@newqos create qos type=linux−htb other−config:max−rate=1000000 queues:0=@newqueue −− −−id=@newqueue create queue other−config:min−rate=1000000 other−config:max−rate=1000000
16、workstation中linux設置共享目錄
必須安裝vmtools,然後在workstation中設置共享目錄,然後在/mnt/hgfs中可看到共享的文件
17、workstation中安裝vmtools
編輯VM設置,選擇install vmtools,vmtools就以光驅的形式掛載到/dev/cdrom中,mount /dev/cdrom /mnt,然後將文件拷走(在mnt下無法完成解壓),將安裝文件解壓然後進入目錄安裝
18、drwxr-xr-x與drwxr-xr-x.後面的點
無點:drwxr-xr-x 表明系統selinux已經關閉
有點:drwxr-xr-x. 表明系統的selinux未關閉
19、mount
umount -i -d -r -n -v -f /directory
20、恢復vg
[root@openfiler2 ~]# pvs
/dev/for_nebula/for_nebula: Checksum error
PV VG Fmt Attr PSize PFree
/dev/for_nebula/for_nebula lvm2 a- 428.09g 428.09g
/dev/sda4 for_nebula lvm2 a- 428.09g 0
<p>修復辦法:</p># vgcfgrestore -f /etc/lvm/backup/system system
Restored volume system
<p>卷組完成恢復,然後激活後查看</p>#vgchange – ay system
1 logical volume(s) in volume group "system" now active
21、rpm --nodeps
Don’t check dependencies before uninstalling the packages.
22、systemctl list-unit-files|grep enabled
23、yum
yum check-update 檢查可更新的所有軟件包
yum update 下載更新系統已安裝的所有軟件包
yum upgrade 大規模的版本升級,與yum update不同的是,連舊的淘汰的包也升級
yum install 安裝新軟件包
yum update 更新指定的軟件包
yum remove 卸載指定的軟件包
yum groupinstall 安裝指定軟件組中的軟件包
yum groupupdate 更新指定軟件組中的軟件包
yum groupremove 卸載指定軟件組中的軟件包
yum grouplist 查看系統中已經安裝的和可用的軟件組
yum list 列出資源庫中所有可以安裝或更新以及已經安裝的rpm包
yum list 列出資源庫中與正則表達式匹配的可以安裝或更新以及已經安裝的rpm包
yum list available 列出資源庫中所有可以安裝的rpm包
yum list available 列出資源庫中與正則表達式匹配的所有可以安裝的rpm包
yum list updates 列出資源庫中所有可以更新的rpm包
yum list updates 列出資源庫中與正則表達式匹配的所有可以更新的rpm包
yum list installed 列出資源庫中所有已經安裝的rpm包
yum list installed 列出資源庫中與正則表達式匹配的所有已經安裝的rpm包
yum list extras 列出已經安裝的但是不包含在資源庫中的rpm包
yum list extras 列出與正則表達式匹配的已經安裝的但是不包含在資源庫中的rpm包
yum list recent 列出最近被添加到資源庫中的軟件包
yum search 檢測所有可用的軟件的名稱、描述、概述和已列出的維護者,查找與正則表達式匹配的值
yum provides 檢測軟件包中包含的文件以及軟件提供的功能,查找與正則表達式匹配的值
yum clean headers 清除緩存中的rpm頭文件
yum clean packages 清除緩存中rpm包文件
yum clean all 清除緩存中的rpm頭文件和包文件
yum deplist 顯示軟件包的依賴信息
24、用戶和組
# chmod ug+w,o-x log2015.log
使所有admins下創建的文件都集成admins文件夾所屬組(+s):
# chmod g+s admins/
創建不能登錄的用戶:# useradd huboss -s /sbin/nologin