昔はこれら全て1つ1つがアプリだった。粒度が小さく、基本的には役割分担が明確だったので Unix哲学の象徴だと言える。

略語の意味を示すために説明は英語表記。

シェルコマンド

コマンド 説明
!! 直前に実行したコマンドを実行
Ctrl + r 履歴を検索して実行
CMD1 ; CMD2 CMD1 を実行してから CMD2 を実行
CMD1 && CMD2 CMD1 の終了ステータスが「0」なら CMD2 を実行
CMD1 || CMD2 CMD1 の終了ステータスが「0」以外なら CMD2 を実行
CMD1 | CMD2 CMD1 の出力を、CMD2 の入力へと渡すパイプ
>, 1> 標準出力先を指定
>> 標準出力先を指定(追記)
2> 標準エラー出力先を指定
&> 標準出力先、標準エラー出力先の両方を指定
<< eof here document(EOF文字が出現するまでの内容を標準入力とする)
vi /etc/profile 全ユーザに共通するシェル環境を設定

シェルスクリプト

if test -f /home/lpicuser/lpic.sh
then
    /home/lpicuser/lpic.sh
else
    /home/lpicuser/default.sh
fi

コピー&ペースト

Linux では通常の「クリップボード」に加えて「X・プライマリ・セレクション」も利用できる。

コマンド 説明
ハイライト + ホイールボタン ハイライト部分を新規にペースト
xclip clip to X-selections and clipboard

カーネル管理

コマンド 説明
grub-mkconfig generate a GRUB configuration file
mkinitramfs initramfs image generator ( Debian )
dracut initramfs image generator ( RH )
dmesg display Kernel message ring
lsmod list Linux Kernel modules
modinfo show information about a Kernel modules
insmod insert a Kernel module
rmmod remove a Kernel module
depmod generate modules.dep
modprobe add and remove modules from Kernel

デバイス管理

コマンド 説明
lscpu list CPU info
dmidecode dumping a computer's DMI table contents
free free memory
vmstat virtual memory statistics
lsblk list storage, partition infomation
df disk free on filesystem
du disk used on directory
lspci list Peripheral Component Interconnect devices
lsusb lsit USB devices
lsscsi list SCSI devices
hwclock set hardware clock
hdparm show HDD/SATA/IDE parameters
sdparm access SCSI mode page
loadkeys loadkeybords
wodim write to CD/DVD
growisofs write iso image to DVD

パーティション管理

コマンド 説明
fdisk fixed disk. manipulate disk partition table
gdisk GUID Partition Table (GPT) manipulator
parted a partition edit program
gparted GNU partition edit program
partx show partitions
mkswap make a Linux swap area
swapon enable devices and files for swapping
swapoff disable devices and files for swapping

ファイルシステム管理

コマンド 説明
mke2fs make an ext2/ext3/ext4 filesystem
tune2fs adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems
e2fsck check a Linux ext2/ext3/ext4 file system
mkfs make a Linux filesystem
fsck file system check
debugfs ext2/ext3/ext4 file system debugger
mount mount a filesystem
umount unmount a filesystem

システム管理

コマンド 説明
systemctl system mamager
screen terminal screen manager
setterm terminal settings
tmux ?
chvt change vertual terminal
uptime Tell how long the system has been running.
uname show system information
arch ( = uname -m) show system hardware name
hostname hostname
hostnamectl mamage hostname
init system mamager
initctl ?
chkconfig old way of systemctl
runlevel show runlevel
update-rc.d set System-V initial links
sysctl configure Kernel parameters
ldd Library DepenDencies
ldconfig ldd configure
logger enter message to system log
journalctl system log manager
halt halt, power off, reboot machine
shutdown shutdown machine
which locate a command
whereis locate the binary, source, and manual page files for a command
busybox command tool box

プロセス管理

コマンド 説明
top ( = htop ) show top processes
pstree show machine's running processes as tree
ps show machine's running processes
pgrep process grep. look up PID using process's name
pkill kill processes by name and other attributes
killall kill all processes by name
kill kill process by PID
nice set program priority
renice alter program priority
lsof list files opened by processes
pidof process id open file
fuser identify file opening process
pwdx pwd for process
jobs show working jobs
bg doing job at background
fg doing job at forgraound
nohup run command without logout hang up

ユーザ管理

コマンド 説明
last show a listing of last logged in users
lastlog all users' the most recent login
w / who show logged-in users
users show logged-in users
groups show user's groups
useradd add a user ( useradd -m -s /bin/bash -G sudo hoge )
usermod modify a user
userdel delete a user
groupadd add a group
groupmod modify a group
groupdel delete a group
getent get entries from nsswitch.conf
passwd set or change user's password
gpasswd manage group password
newgrp log in to a new group
chpasswd change password in batch mode
chage change / show user's account and password age
chsh change login shell
pwck check password file
finger user's fingerprint
chfn change user's fingerprint
grpck check group file
vipw / vigr edit password / group file
pwconv convert password file
quota show user and group quota of strage
repquota show quota status
quotaon activate quota
edquota edit quota for user disk
write / wall write a massage to all users
htpasswd httpd basic authentication
htdigest httpd digest authentication

ユーザツール

コマンド 説明
id show user's id
whoami who am i ?
date show date
tzselect select timezone
timedatectl Control the system time and date
cal show calendar
set show shell environment. set >> env
unset unset shell environment
env show user's enviroment
printenv (= env) show environment
locale get locale-specific information
export export environment from shell's env to user's env
history show command history
alias make alias
unalias unmake alias
fc ?
su switch user
sudo switch user do
sg switch group
chroot run command with special root directory
crontab manage cron
expect expect response
at ?
script ?
stdbuf modify buffering
time show round trip time
watch run program periodically
sleep set a moment before run
exit exit terminal
make compile file
install copy files
yes always say "yes"
xargs x-arguments
git git
cvs cvs
svn svn
mysql mysql client / server
mysqldump mysql dump databases
xl ?
VBoxManage ?
lpadmin configure cups printers
lpstat show cups printing status
lp submit files for printing
lpr subimt files for printing
cancel cancel printing job

ファイル / ディレクトリ操作

コマンド 説明
pwd print working directory
tree show tee-style directory
ls list
cd change directory
find find files
locate location of files
updatedb update database for locate
basename base name of file
dirname name of directory
file show types of files
stat status of file
lsattr list file attributes on a Linux second extended file system
chattr change file attribution
chmod change mode
chown change owner of file
chgrp change owner group
mkdir make a directory
rmdir remove direcotory
touch touch a file
cp copy
mv move, change
rm remove
shred shred files
ln make links between files
readlink show symbolic link
tmpwatch ?
umask user mask
split split a file into pieces. 1,000 rows chunk as default
truncate shrink or expand file
tar type archive
cpio (= tar) copy files to and from archives
gzip / gunzip zip / unzip
mktemp make temporary file
convmv convert move
dd dump datas
pv pipe viewer
base64 base64 encode / decode
od dump files in octal and other formats
md5sum / sha1sum calculate md5 or sha1
iconv change file encoding
strings show string parts in data file
uuencode ?
uudecode ?
lhasa ?
unrar ?
pushd ?

テキスト操作

コマンド 説明
echo display a line of text
tee write std-output and life
more viewer
less viewer
head show head part of file
tail / tailf show tail part of file
cat concatinate
tac etanitacnoc
nl with number line
grep global reguler expression print
uniq show only uniq part
wc word count
cut cut
rev reverse
seq sequence
sort sort lines of text files
tr translate or delete characters
ex ex mode of vi
ed line editor (Ken Thompson)
sed stream editor
vi visual editor
awk patter scanning and processing language
nkf ?
patch patch a diff file
diff compare two files line by line
comm compare two files line by line
cmp compare two files byte by byte
col remove \n etc.
column columnate list
colrm column remove
expand expand tab to space
unexpand space to tab
paste marge files
join marge same parts of files
bc calculator
let calculate
factor show factor numbers
expr evaluate expression
test ?
shuf shuffle some value
fold wrap words in lines
pr for printer format

パッケージ管理

コマンド 説明
apt advanced packaging tool
dpkg Debian package manager
dpkg-reconfigure reconfigure an already installed package
yum yellodog-linux update manager
rpm RedHat package manager
rpm2cpio rpm file to cpio

ネットワーク

コマンド 説明
netstat network status
ss show sockets
arp ip neighbors
ipcalc ip calculator
route ip routing table manager
ip internet protocol mnager
ifconfig interface configure
iwconfig interface wireless configure
iwlist show Wi-Fi access-point
wpa_supplicant protected Wi-Fi cliant
nmtui NetworkManager text-user interface
nmcli NetworkManager command-line interface
iptables packet filtering tool
ufw uncomplicated firewall manager
firewall-cmd firewall manager
ping send ICMP ECHO_REQUEST
traceroute print the route packets trace to network host
arping send ARP REQUEST to neighber
ntpq NTP quary
ntpdate set the date via NTP
clockdiff time lag to remote host
ssh secure shell
ssh-keygen ssh-key generator
ssh-copy-id ssh copy id
scp secure copy
rsync remote file-copying tool
telnet ?
ftp file transfer program
sftp secure ftp
wget WWW downloader
curl Client URL Request Library
tcpdump dump traffic on a network
tshark ?
brctl ?
host DNS lookup
nslookup DNS lookup
dig DNS lookup
whois show IANA info

ネットワークセキュリティ

コマンド 説明
nmap Network Mapper
netcat / nc network investigator
gpg OpenPGP encryption and signing tool
openssl SSL / TLS tool kit
pwgen password generator

ネットワークツール

コマンド 説明
mail send and receive mail
mailq ?
newaliases mail alias
w3m WWW monitor
showmount show NFS server's exports status
rdesktop remote desktop

TIPS

画像を一括して圧縮

# find /var/www/html/wp-content/uploads/ -name *.jpg | xargs -t -I{} convert {} -sampling-factor 4:2:0 -strip -quality 90 -interlace JPEG -colorspace sRGB {}
  • root が/etc/に nologinファイルを作成すると全ての一般ユーザがログイン不可になる。ファイルに内容を記載した場合は、それがログイン拒否時に表示される