編集の要約なし |
|||
(同じ利用者による、間の49版が非表示) | |||
1行目: | 1行目: | ||
昔はこれら全て1つ1つが''アプリ''だった。粒度が小さく、基本的には役割分担が明確だったので | 昔はこれら全て1つ1つが''アプリ''だった。粒度が小さく、基本的には役割分担が明確だったので Unix哲学の象徴だと言える。略語の意味を示すために説明は英語表記。 | ||
__TOC__ | __TOC__ | ||
14行目: | 12行目: | ||
|<code><nowiki>!!</nowiki></code> || 直前に実行したコマンドを実行 | |<code><nowiki>!!</nowiki></code> || 直前に実行したコマンドを実行 | ||
|- | |- | ||
| | |<code>Ctrl</code> + <code>r</code> || 履歴を検索して実行 | ||
|- | |- | ||
|<code>CMD1 ; CMD2</code> || CMD1 を実行してから CMD2 | |<code>CMD1 ; CMD2</code> || CMD1 を実行してから CMD2 を実行 | ||
|- | |- | ||
|<code>CMD1 && CMD2</code> || CMD1 の終了ステータスが「0」なら CMD2 | |<code>CMD1 && CMD2</code> || CMD1 の終了ステータスが「0」なら CMD2 を実行 | ||
|- | |- | ||
|<code><nowiki>CMD1 || CMD2</nowiki></code> || CMD1 の終了ステータスが「0」以外なら CMD2 | |<code><nowiki>CMD1 || CMD2</nowiki></code> || CMD1 の終了ステータスが「0」以外なら CMD2 を実行 | ||
|- | |- | ||
|<code><nowiki>CMD1 | CMD2</nowiki></code> || CMD1 の出力を、CMD2 の入力へと渡すパイプ | |<code><nowiki>CMD1 | CMD2</nowiki></code> || CMD1 の出力を、CMD2 の入力へと渡すパイプ | ||
36行目: | 34行目: | ||
|<code>vi /etc/profile</code> || 全ユーザに共通するシェル環境を設定 | |<code>vi /etc/profile</code> || 全ユーザに共通するシェル環境を設定 | ||
|} | |} | ||
==シェルスクリプト== | |||
if test -f /home/lpicuser/lpic.sh | |||
then | |||
/home/lpicuser/lpic.sh | |||
else | |||
/home/lpicuser/default.sh | |||
fi | |||
* [[シェルスクリプト]] まとめ | |||
==コピー&ペースト== | ==コピー&ペースト== | ||
59行目: | 67行目: | ||
!説明 | !説明 | ||
|- | |- | ||
|<code>grub-mkconfig</code> || generate a GRUB configuration file | |<code>[[grub-mkconfig]]</code> || generate a GRUB configuration file | ||
|- | |- | ||
|<code>mkinitramfs</code> || initramfs image generator ( Debian ) | |<code>mkinitramfs</code> || initramfs image generator ( Debian ) | ||
103行目: | 111行目: | ||
|- | |- | ||
|<code>[[du]]</code> | |<code>[[du]]</code> | ||
|disk used | |disk used on directory | ||
|- | |- | ||
|<code>[[lspci]]</code> || list Peripheral Component Interconnect devices | |<code>[[lspci]]</code> || list Peripheral Component Interconnect devices | ||
158行目: | 166行目: | ||
|make an ext2/ext3/ext4 filesystem | |make an ext2/ext3/ext4 filesystem | ||
|- | |- | ||
|<code>tune2fs</code> | |<code>[[tune2fs]]</code> | ||
|adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems | |adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems | ||
|- | |- | ||
|<code>e2fsck</code> | |<code>[[e2fsck]]</code> | ||
|check a Linux ext2/ext3/ext4 file system | |check a Linux ext2/ext3/ext4 file system | ||
|- | |- | ||
228行目: | 236行目: | ||
|set System-V initial links | |set System-V initial links | ||
|- | |- | ||
|<code>sysctl</code> | |<code>[[sysctl]]</code> | ||
|configure Kernel parameters | |configure Kernel parameters | ||
|- | |- | ||
|<code>ldd</code> | |<code>[[ldd]]</code> | ||
| | |Library DepenDencies | ||
|- | |- | ||
|<code>ldconfig</code> | |<code>ldconfig</code> | ||
246行目: | 254行目: | ||
|halt, power off, reboot machine | |halt, power off, reboot machine | ||
|- | |- | ||
|<code>shutdown</code> | |<code>[[shutdown]]</code> | ||
|shutdown machine | |shutdown machine | ||
|- | |- | ||
276行目: | 284行目: | ||
|show machine's running processes | |show machine's running processes | ||
|- | |- | ||
|<code>[[ | |<code>[[pgrep]]</code> | ||
| | |process grep. look up PID using process's name | ||
|- | |||
|<code>pkill</code> | |||
|kill processes by name and other attributes | |||
|- | |- | ||
|<code> | |<code>killall</code> | ||
| | |kill all processes by name | ||
|- | |- | ||
|<code>[[kill]]</code> | |<code>[[kill]]</code> | ||
|kill process by PID | |kill process by PID | ||
|- | |- | ||
|<code> | |<code>[[nice]]</code> | ||
| | |set program priority | ||
|- | |- | ||
|<code> | |<code>[[renice]]</code> | ||
| | |alter program priority | ||
|- | |- | ||
|<code>lsof</code> | |<code>[[lsof]]</code> | ||
|list files opened by processes | |list files opened by processes | ||
|- | |- | ||
358行目: | 366行目: | ||
|<code>groupdel</code> | |<code>groupdel</code> | ||
|delete a group | |delete a group | ||
|- | |||
|<code>[[getent]]</code> | |||
|get entries from nsswitch.conf | |||
|- | |- | ||
|<code>[[passwd]]</code> | |<code>[[passwd]]</code> | ||
394行目: | 405行目: | ||
|<code>pwconv</code> | |<code>pwconv</code> | ||
|convert password file | |convert password file | ||
|- | |||
|<code>quota</code> | |||
|show user and group quota of strage | |||
|- | |||
|<code>repquota</code> | |||
|show quota status | |||
|- | |||
|<code>quotaon</code> | |||
|activate quota | |||
|- | |- | ||
|<code>edquota</code> | |<code>edquota</code> | ||
446行目: | 466行目: | ||
|(= env) show environment | |(= env) show environment | ||
|- | |- | ||
|<code>locale</code> | |<code>[[locale]]</code> | ||
|get locale-specific information | |get locale-specific information | ||
|- | |- | ||
566行目: | 586行目: | ||
|show tee-style directory | |show tee-style directory | ||
|- | |- | ||
|<code>ls</code> | |<code>[[ls]]</code> | ||
|list | |list | ||
|- | |- | ||
623行目: | 643行目: | ||
|move, change | |move, change | ||
|- | |- | ||
|<code>rm</code> | |<code>[[rm]]</code> | ||
|remove | |remove | ||
|- | |- | ||
641行目: | 661行目: | ||
|user mask | |user mask | ||
|- | |- | ||
|<code>split</code> | |<code>[[split]]</code> | ||
|split a file into pieces. 1,000 rows chunk as default | |split a file into pieces. 1,000 rows chunk as default | ||
|- | |- | ||
710行目: | 730行目: | ||
|display a line of text | |display a line of text | ||
|- | |- | ||
|<code>tee</code> | |<code>[[tee]]</code> | ||
|write std-output and life | |write std-output and life | ||
|- | |- | ||
716行目: | 736行目: | ||
|viewer | |viewer | ||
|- | |- | ||
|<code>less</code> | |<code>[[less]]</code> | ||
|viewer | |viewer | ||
|- | |- | ||
725行目: | 745行目: | ||
|show tail part of file | |show tail part of file | ||
|- | |- | ||
|<code>cat</code> | |<code>[[cat]]</code> | ||
|concatinate | |concatinate | ||
|- | |- | ||
762行目: | 782行目: | ||
|- | |- | ||
|<code>ed</code> | |<code>ed</code> | ||
|line editor | |line editor (Ken Thompson) | ||
|- | |- | ||
|<code>[[sed]]</code> | |<code>[[sed]]</code> | ||
868行目: | 888行目: | ||
!コマンド | !コマンド | ||
!説明 | !説明 | ||
|- | |||
|<code>[[netstat]]</code> | |||
|network status | |||
|- | |- | ||
|<code>[[ss]]</code> | |<code>[[ss]]</code> | ||
|show sockets | |show sockets | ||
|- | |- | ||
|<code>arp</code> | |<code>arp</code> | ||
880行目: | 900行目: | ||
|<code>ipcalc</code> | |<code>ipcalc</code> | ||
|ip calculator | |ip calculator | ||
|- | |- | ||
|<code>route</code> | |<code>route</code> | ||
|ip routing table manager | |ip routing table manager | ||
|- | |- | ||
|<code>ifconfig</code> | |<code>[[ip]]</code> | ||
|internet protocol mnager | |||
|- | |||
|<code>[[ifconfig]]</code> | |||
|interface configure | |interface configure | ||
|- | |- | ||
914行目: | 934行目: | ||
|firewall manager | |firewall manager | ||
|- | |- | ||
|<code>ping</code> | |<code>[[ping]]</code> | ||
|send ICMP ECHO_REQUEST | |send ICMP ECHO_REQUEST | ||
|- | |- | ||
|<code> | |<code>[[traceroute]]</code> | ||
| | |print the route packets trace to network host | ||
|- | |- | ||
|<code>arping</code> | |<code>arping</code> | ||
971行目: | 991行目: | ||
|? | |? | ||
|- | |- | ||
|<code>host</code> | |<code>[[host]]</code> | ||
|DNS lookup | |DNS lookup | ||
|- | |- | ||
977行目: | 997行目: | ||
|DNS lookup | |DNS lookup | ||
|- | |- | ||
|<code>dig</code> | |<code>[[dig]]</code> | ||
|DNS lookup | |DNS lookup | ||
|- | |- | ||
998行目: | 1,018行目: | ||
|network investigator | |network investigator | ||
|- | |- | ||
|<code>gpg</code> | |<code>[[gpg]]</code> | ||
| | |OpenPGP encryption and signing tool | ||
|- | |- | ||
|<code>openssl</code> | |<code>openssl</code> | ||
1,039行目: | 1,059行目: | ||
===画像を一括して圧縮=== | ===画像を一括して圧縮=== | ||
# 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 {} | # 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 が<code>/etc/</code>に nologinファイルを作成すると全ての一般ユーザがログイン不可になる。ファイルに内容を記載した場合は、それがログイン拒否時に表示される |
2022年11月29日 (火) 23:35時点における最新版
昔はこれら全て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ファイルを作成すると全ての一般ユーザがログイン不可になる。ファイルに内容を記載した場合は、それがログイン拒否時に表示される