[Linux] User Operations
- 查看線上使用者
who
- 查看自身
whoami
- 登出其他使用者
sudo pkill -u username
who
whoami
sudo pkill -u username
gcc -o targetname sourcename.c ; ./targetname
ll -t
find targetdir targetfile
find targetdir -type mytype -name targetfile
rm -rf targetfile
-r:遞迴刪除資料夾內所有內容 -f:強制刪除
#壓縮
tar -zcvf out.tar.gz sourcedir
#解壓縮
tar -zxvf in.tar.gz -C targetdir
#檢視
tar -ztvf in.tar.gz
#複製單一檔案並改名為targetfile
cp sourcefile targetfile
#複製單一檔案至某目錄下
cp sourcefile targetdir
#複製資料夾
cp -r sourcedir targetdir
mv sourcefile targetfile
#一次移動多個檔案
mv -t targetdir file1 file2 ...
#格式化更名檔案,將matchfile符合exp1的字替換成exp2
rename 's/exp1/exp2/g' matchfile
lsblk
freeBSD:
camcontrol devlist
example:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1.5G 0 rom /media/hubert/Ubuntu 16.04.3 LTS amd64
sda 8:0 0 40G 0 disk
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 2G 0 part [SWAP]
└─sda1 8:1 0 38G 0 part /
df mydir #查看zfs分割掛載
gpart show mydisk #查看gpt分割
fdisk -l /dev/sda
example:
若出現:WARNING: GPT (GUID Partition Table) detected,則是GPT
若正常顯示磁碟分割,則是MBR
eject
cat /proc/version
uname -a
#lsb_release -a
LSB Version: 1.3
Distributor ID: RedHatEnterpriseAS
Descrīption: Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
Release: 4
Codename: NahantUpdate1
ifconfig
.curl icanhazip.com
rpm-qa kernel
–count=n, n is the number of kernels YOU WANT TO LEFT.
yum install yum-utils
package-cleanup --oldkernels --count=1
edit /etc/yum.conf
installonly_limit=1