[Linux] コマンド

コマンド内容
adduser
apt
awk
bcecho “1+2+3” | bc
cal
catcat file.txtconcatenate files and print on the standard output
cd
chmodchange file mode bits
chownchange file owner and group
clear
cmp
cp
curltransfer a URL
dfreport file system disk space usage
diff
echoecho “Hello World!” > file.txtファイルを新規作成する
exit
findsearch for files in a directory hierarchy
fingerユーザーの情報を表示する
freeDisplay amount of free and used memory in the system
grep
head
history
hostnameホスト名を表示する
htopinteractive process viewer
ifconfig非推奨。代わりにipを使うこと
ip addrip addr
ip link
ip -s link
iptables
ip6tables
administration tool for IPv4/IPv6 packet filtering and NAT
kill
lessopposite of more
lnリンクを作成する
ls
lscpudisplay information about the CPU architecture
man
mkdir
morefile perusal filter for crt viewing
mv
nanonano file.txt
neofetch
netstat代わりにssを使うこと
passwd
ping
pkill
printenv環境変数を出力する
psreport a snapshot of the current processes
pwdprint working directory
reboot
resolvectl status
rm
rsyncrsync -r /path/to/local_source/ user@remote:/path/to/remote_destination/
rsync -r user@remote:/path/to/remote_source/ /path/to/local_destination/
ファイルやディレクトリを転送する
(ディレクトリを転送する場合は-rオプションが必要)
scp非推奨
sedstream editor for filtering and transforming text
sftpsftp <hostname>
lls
lcd
put <local_file>
ls
cd
get <remote_file>
サーバーとの間でファイルを送受信する
shredshred file.txtファイルを完全に削除する
shutdownshutdown -h now代わりにsystemctl poweroffを使うこと
sort
ssTCP/UDPのポート開放状態を確認
ss -nltu
another utility to investigate sockets
sshssh <hostname>OpenSSH remote login client
su
sudo
systemctlsystemctl poweroff
systemctl reboot
systemctl suspend
Control the systemd system and service manager
tail
teecat <<EOF | sudo tee -a /etc/hosts
192.168.0.100 company.com
EOF
read from standard input and write to standard output and files
sudoでファイルに書き込む場合などに使う
-aは追記
top
touchchange file timestamps
traceroute
ufwsudo ufw status
sudo ufw enable
sudo ufw reload

sudo ufw app list
sudo ufw allow ‘Nginx Full’

TCP/UDPポート開放
sudo ufw allow 80
sudo ufw reload

UDPポート開放
sudo ufw allow 80/udp
sudo ufw reload

SSH接続用ポート開放
sudo ufw allow 22

ポート削除
sudo ufw status
sudo ufw delete <ステータス一覧上の番号>
(Uncomplicated Firewall)
program for managing a netfilter firewall

内部ではiptablesが使われている
unameすべての情報を表示
uname -a
print system information
unzip
useradd
vimvim file.txt
wgetThe non-interactive network downloader
whatis
whereis
which
whoami
zip

リダイレクト/パイプ

>出力をリダイレクト(上書き)。1>と同義
>>出力をリダイレクト(追記)
2>標準エラー出力をリダイレクト
2>&1標準エラー出力を標準出力にリダイレクト
<入力をリダイレクト。0<と同義
cat <<EOF> fruits.txt
apple
grape
orange
EOF
ヒアドキュメント(上書き)。>ではなく>>とすると追記
cmd1 | cmd2cmd1の標準出力をcmd2の標準入力に渡す
cmd1 |& cmd2cmd1の標準出力と標準エラー出力をcmd2の標準入力に渡す
0:標準入力、1:標準出力、2:標準エラー出力