|
@@ -1,216 +1,216 @@
|
|
|
|
|
|
% Shell Usage
|
|
% Shell Usage
|
|
|
|
|
|
-# Re-call last input with sudo
|
|
|
|
|
|
+# 用sudo重新执行上一条命令 | Re-call last input with sudo
|
|
sudo !!
|
|
sudo !!
|
|
|
|
|
|
-# Help
|
|
|
|
|
|
+# 帮助 | Help
|
|
help cd / help dir (...)
|
|
help cd / help dir (...)
|
|
|
|
|
|
-# Finding Help
|
|
|
|
|
|
+# 查找帮助 | Finding Help
|
|
apropos directory / apropos search (...)
|
|
apropos directory / apropos search (...)
|
|
|
|
|
|
-# Define custom startup screen
|
|
|
|
|
|
+# 定义自定义启动屏幕 | Define custom startup screen
|
|
sudo nano /etc/motd
|
|
sudo nano /etc/motd
|
|
|
|
|
|
-# Run a script as background process
|
|
|
|
|
|
+# 以后台进程运行脚本 | Run a script as background process
|
|
<process> &
|
|
<process> &
|
|
|
|
|
|
-#List all running processes
|
|
|
|
|
|
+# 列出所有正在运行的进程 | List all running processes
|
|
ps -A
|
|
ps -A
|
|
|
|
|
|
-# Kill a running process
|
|
|
|
|
|
+# 终止正在运行的进程 | Kill a running process
|
|
killall <Process-name>
|
|
killall <Process-name>
|
|
|
|
|
|
% Shell System
|
|
% Shell System
|
|
|
|
|
|
-# Get the current path
|
|
|
|
|
|
+# 获取当前路径 | Get the current path
|
|
pwd
|
|
pwd
|
|
|
|
|
|
-# Get the current hostname
|
|
|
|
|
|
+# 获取当前主机名 | Get the current hostname
|
|
hostname
|
|
hostname
|
|
|
|
|
|
-# Get the current users
|
|
|
|
|
|
+# 获取当前用户 | Get the current users
|
|
users
|
|
users
|
|
|
|
|
|
-# Show calendar
|
|
|
|
|
|
+# 显示日历 | Show calendar
|
|
cal
|
|
cal
|
|
|
|
|
|
-# Show today's date
|
|
|
|
|
|
+# 显示当前日期 | Show today's date
|
|
date
|
|
date
|
|
|
|
|
|
-# Exit terminal
|
|
|
|
|
|
+# 退出终端 | Exit terminal
|
|
exit
|
|
exit
|
|
|
|
|
|
% Shell Permissions
|
|
% Shell Permissions
|
|
|
|
|
|
-# Use -R option to change permissions recursively.
|
|
|
|
|
|
+# 使用-R选项递归更改权限 | Use -R option to change permissions recursively.
|
|
ps -ef | grep apache | grep -v grep
|
|
ps -ef | grep apache | grep -v grep
|
|
|
|
|
|
-# Change group
|
|
|
|
|
|
+# 更改组 | Change group
|
|
chgrp <group-name-from> <group-name-to>
|
|
chgrp <group-name-from> <group-name-to>
|
|
|
|
|
|
% Shell Directories
|
|
% Shell Directories
|
|
|
|
|
|
-# List directory contents
|
|
|
|
|
|
+# 列出目录内容 | List directory contents
|
|
ls
|
|
ls
|
|
|
|
|
|
-# List all directory contents
|
|
|
|
|
|
+# 列出所有目录内容 | List all directory contents
|
|
ll
|
|
ll
|
|
|
|
|
|
-# List all directory contents sorted by time edited
|
|
|
|
|
|
+# 按编辑时间列出所有目录内容 | List all directory contents sorted by time edited
|
|
ls -alt
|
|
ls -alt
|
|
|
|
|
|
-# List directory (wildcard matching)
|
|
|
|
|
|
+# 列出目录(通配符匹配) | List directory (wildcard matching)
|
|
ls *.<txt>
|
|
ls *.<txt>
|
|
|
|
|
|
-# List all files of type
|
|
|
|
|
|
+# 列出指定类型的所有文件 | List all files of type
|
|
find . -name '*.<txt>' -print
|
|
find . -name '*.<txt>' -print
|
|
|
|
|
|
-# Go back to previous directory
|
|
|
|
|
|
+# 返回上一个目录 | Go back to previous directory
|
|
cd -
|
|
cd -
|
|
|
|
|
|
-# Make (empty) directory
|
|
|
|
|
|
+# 创建(空)目录 | Make (empty) directory
|
|
mkdir <dirname>
|
|
mkdir <dirname>
|
|
|
|
|
|
-# Remove (empty) directory
|
|
|
|
|
|
+# 删除(空)目录 | Remove (empty) directory
|
|
rmdir <dirname>
|
|
rmdir <dirname>
|
|
|
|
|
|
-# Remove directory with all contents without prompt
|
|
|
|
|
|
+# 无提示删除目录及其所有内容 | Remove directory with all contents without prompt
|
|
rm -rf <dirname>
|
|
rm -rf <dirname>
|
|
|
|
|
|
-# Remove directory contents and keep directory
|
|
|
|
|
|
+# 删除目录内容但保留目录 | Remove directory contents and keep directory
|
|
rm -rf *
|
|
rm -rf *
|
|
|
|
|
|
-# Change directory
|
|
|
|
|
|
+# 切换目录 | Change directory
|
|
cd <dirname>
|
|
cd <dirname>
|
|
|
|
|
|
% shell Symlinks
|
|
% shell Symlinks
|
|
|
|
|
|
-# Create symlink
|
|
|
|
|
|
+# 创建符号链接 | Create symlink
|
|
ln -s <source-dirname> <destination-dirname>
|
|
ln -s <source-dirname> <destination-dirname>
|
|
|
|
|
|
-# Update symlink
|
|
|
|
|
|
+# 更新符号链接 | Update symlink
|
|
ln -sfn <source-dirname> <destination-dirname>
|
|
ln -sfn <source-dirname> <destination-dirname>
|
|
|
|
|
|
-# Remove symlink
|
|
|
|
|
|
+# 删除符号链接 | Remove symlink
|
|
unlink <sample-dirname>
|
|
unlink <sample-dirname>
|
|
|
|
|
|
% Shell Files
|
|
% Shell Files
|
|
|
|
|
|
-# Make (empty) file
|
|
|
|
|
|
+# 创建(空)文件 | Make (empty) file
|
|
touch <filename-txt>
|
|
touch <filename-txt>
|
|
|
|
|
|
-# Duplicate file
|
|
|
|
|
|
+# 复制文件 | Duplicate file
|
|
cp <filename> <file-copyname>
|
|
cp <filename> <file-copyname>
|
|
|
|
|
|
-# Copy/Page folder with content
|
|
|
|
|
|
+# 复制/分页文件夹及其内容 | Copy/Page folder with content
|
|
cp -a <old-folder>/ <new-folder>
|
|
cp -a <old-folder>/ <new-folder>
|
|
|
|
|
|
-# Move/Rename file
|
|
|
|
|
|
+# 移动/重命名文件 | Move/Rename file
|
|
mv <current-filename-path> <new-filename-path>
|
|
mv <current-filename-path> <new-filename-path>
|
|
|
|
|
|
-# Move/Rename file and prompt before overwriting an existing file
|
|
|
|
|
|
+# 移动/重命名文件并在覆盖现有文件前提示 | Move/Rename file and prompt before overwriting an existing file
|
|
mv -i <current-filename> <new-filename>
|
|
mv -i <current-filename> <new-filename>
|
|
|
|
|
|
-# Remove file
|
|
|
|
|
|
+# 删除文件 | Remove file
|
|
rm <filename-txt>
|
|
rm <filename-txt>
|
|
|
|
|
|
-# Write to file (will overwrite existing content)
|
|
|
|
|
|
+# 写入文件(将覆盖现有内容) | Write to file (will overwrite existing content)
|
|
cat > <filename-txt>
|
|
cat > <filename-txt>
|
|
|
|
|
|
-# Search for a filename-(not content!) in the current directory
|
|
|
|
|
|
+# 在当前目录中搜索文件名(非内容) | Search for a filename-(not content!) in the current directory
|
|
find <filename-txt>
|
|
find <filename-txt>
|
|
|
|
|
|
-# Search for a string inside all files in the current directory and subdrectories
|
|
|
|
|
|
+# 在当前目录和子目录的所有文件中搜索字符串 | Search for a string inside all files in the current directory and subdrectories
|
|
grep -r <string> *
|
|
grep -r <string> *
|
|
|
|
|
|
-# Search and replace within file
|
|
|
|
|
|
+# 在文件中搜索并替换 | Search and replace within file
|
|
sed -i s/<original-text>/<new-text>/g <filename-txt>
|
|
sed -i s/<original-text>/<new-text>/g <filename-txt>
|
|
|
|
|
|
-# MD5 hash for files
|
|
|
|
|
|
+# 文件的MD5哈希值 | MD5 hash for files
|
|
md5 <filename-txt>
|
|
md5 <filename-txt>
|
|
|
|
|
|
-# MD5 hash for folders
|
|
|
|
|
|
+# 文件夹的MD5哈希值 | MD5 hash for folders
|
|
tar c <folder> | md5sum
|
|
tar c <folder> | md5sum
|
|
|
|
|
|
-# Encrypt file
|
|
|
|
|
|
+# 加密文件 | Encrypt file
|
|
openssl enc -aes-256-cbc -e -in <sample-filename-txt> -out <sample-encrypted-txt>
|
|
openssl enc -aes-256-cbc -e -in <sample-filename-txt> -out <sample-encrypted-txt>
|
|
|
|
|
|
-# Decrypt file
|
|
|
|
|
|
+# 解密文件 | Decrypt file
|
|
openssl enc -aes-256-cbc -d -in <sample-encrypted> -out <sample-filename>
|
|
openssl enc -aes-256-cbc -d -in <sample-encrypted> -out <sample-filename>
|
|
|
|
|
|
% Shell Server
|
|
% Shell Server
|
|
|
|
|
|
-# Access via ssh
|
|
|
|
|
|
+# 通过ssh访问 | Access via ssh
|
|
ssh <username_remote>
|
|
ssh <username_remote>
|
|
|
|
|
|
-# Copy file from server to local
|
|
|
|
|
|
+# 从服务器复制文件到本地 | Copy file from server to local
|
|
scp <username_remote>:<file-to-send-path> <path-to-recieve>
|
|
scp <username_remote>:<file-to-send-path> <path-to-recieve>
|
|
|
|
|
|
-# Copy file from local to server
|
|
|
|
|
|
+# 从本地复制文件到服务器 | Copy file from local to server
|
|
scp <file-to-send> <username_remote>:<where-to-put>
|
|
scp <file-to-send> <username_remote>:<where-to-put>
|
|
|
|
|
|
-# Escape files with spaces in name like this
|
|
|
|
|
|
+# 转义文件名中的空格 | Escape files with spaces in name like this
|
|
<path-to-file>\\\ <name-png>
|
|
<path-to-file>\\\ <name-png>
|
|
|
|
|
|
$ username_remote: cat ~/.ssh/config | grep -i "host "|sed 's/^[ \t]*//g' | awk '{print $2}'
|
|
$ username_remote: cat ~/.ssh/config | grep -i "host "|sed 's/^[ \t]*//g' | awk '{print $2}'
|
|
|
|
|
|
% Shell System
|
|
% Shell System
|
|
|
|
|
|
-# Show disc space
|
|
|
|
|
|
+# 显示磁盘空间 | Show disc space
|
|
df -h
|
|
df -h
|
|
|
|
|
|
-# Show disc space (inodes)
|
|
|
|
|
|
+# 显示磁盘空间(inode) | Show disc space (inodes)
|
|
df -i
|
|
df -i
|
|
|
|
|
|
-# Show disc space for current directory
|
|
|
|
|
|
+# 显示当前目录的磁盘空间 | Show disc space for current directory
|
|
du -hs
|
|
du -hs
|
|
|
|
|
|
-# Current processes (also CPS usage)
|
|
|
|
|
|
+# 当前进程(包括CPU使用率) | Current processes (also CPS usage)
|
|
top or htop
|
|
top or htop
|
|
|
|
|
|
-# Show running php processes
|
|
|
|
|
|
+# 显示正在运行的php进程 | Show running php processes
|
|
ps aux | grep php
|
|
ps aux | grep php
|
|
|
|
|
|
-# Monitor error log (stream as file grows)
|
|
|
|
|
|
+# 监控错误日志(实时显示文件增长) | Monitor error log (stream as file grows)
|
|
tail error.log -f -n 0
|
|
tail error.log -f -n 0
|
|
|
|
|
|
% Shell Apps
|
|
% Shell Apps
|
|
|
|
|
|
-# Start appliction
|
|
|
|
|
|
+# 启动应用程序 | Start appliction
|
|
xdg-open <programme>
|
|
xdg-open <programme>
|
|
|
|
|
|
-# Open finder with current folder
|
|
|
|
|
|
+# 用当前文件夹打开Finder | Open finder with current folder
|
|
open .
|
|
open .
|
|
|
|
|
|
% Shell Variables
|
|
% Shell Variables
|
|
|
|
|
|
-# Register variable
|
|
|
|
|
|
+# 注册变量 | Register variable
|
|
export <TESTING>=<Variable-text>
|
|
export <TESTING>=<Variable-text>
|
|
|
|
|
|
-# Echo variable
|
|
|
|
|
|
+# 输出变量 | Echo variable
|
|
echo $<Variable>
|
|
echo $<Variable>
|
|
|
|
|
|
-# Unset variable
|
|
|
|
|
|
+# 取消设置变量 | Unset variable
|
|
unset <Variable>
|
|
unset <Variable>
|
|
|
|
|
|
% Shell Output & Redirects
|
|
% Shell Output & Redirects
|
|
|
|
|
|
-# Write to file
|
|
|
|
|
|
+# 写入文件 | Write to file
|
|
echo <Hello> > <hello-txt>
|
|
echo <Hello> > <hello-txt>
|
|
|
|
|
|
-# Append content from a file to another file
|
|
|
|
|
|
+# 将一个文件的内容追加到另一个文件 | Append content from a file to another file
|
|
cat <file1-txt> >> <file2-txt>
|
|
cat <file1-txt> >> <file2-txt>
|
|
|
|
|
|
-# Add the amount of lines, words, and characters to <file2-txt>
|
|
|
|
|
|
+# 将行数、单词数和字符数添加到<file2-txt> | Add the amount of lines, words, and characters to <file2-txt>
|
|
cat <file1-txt> | <word-count> | cat > <file2-txt>
|
|
cat <file1-txt> | <word-count> | cat > <file2-txt>
|
|
|
|
|
|
-# Sort the content of a file (like cat)
|
|
|
|
|
|
+# 对文件内容进行排序(类似cat) | Sort the content of a file (like cat)
|
|
sort <hello-txt>
|
|
sort <hello-txt>
|
|
|
|
|
|
-# Save to sorted content to a new file
|
|
|
|
|
|
+# 将排序后的内容保存到新文件 | Save to sorted content to a new file
|
|
cat <file1-txt> | sort > <sorted-file1-txt>
|
|
cat <file1-txt> | sort > <sorted-file1-txt>
|
|
|
|
|
|
-# Sort and remove duplicates and save to a new file
|
|
|
|
|
|
+# 排序并去重后保存到新文件 | Sort and remove duplicates and save to a new file
|
|
sort <file1-txt> | uniq > <uniq-file1-txt>
|
|
sort <file1-txt> | uniq > <uniq-file1-txt>
|