\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Leaves} \pdfinfo{ /Title (linux-command.pdf) /Creator (Cheatography) /Author (Leaves) /Subject (Linux Command Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{5849BF} \definecolor{LightBackground}{HTML}{F4F3FB} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Linux Command Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Leaves} via \textcolor{DarkBackground}{\uline{cheatography.com/71639/cs/18184/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Leaves \\ \uline{cheatography.com/leaves} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 8th December, 2018.\\ Updated 8th December, 2018.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{x{2.16 cm} x{5.84 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{文件操作}} \tn % Row 0 \SetRowColor{LightBackground} ls & 显示 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ls -l & 详细显示 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} ls -a & \seqsplit{显示(包括隐藏文件)} \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} cp \{scr\} \{dest\} & 拷贝文件 \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} rm & 删除文件 \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} rm -r & 删除目录 \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} cat & 输出文件原始内容 \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} touch & 创建或更新文件 \tn % Row Count 10 (+ 1) % Row 8 \SetRowColor{LightBackground} any\_cmd \textgreater{} \{fn\} & \seqsplit{执行任意命令并将标准输出重定向到指定文件} \tn % Row Count 13 (+ 3) % Row 9 \SetRowColor{white} head & 显示文件头10行 \tn % Row Count 14 (+ 1) % Row 10 \SetRowColor{LightBackground} tail & 显示文件尾部10行 \tn % Row Count 15 (+ 1) % Row 11 \SetRowColor{white} diff \{f1\} \{f2\} & 比较两个文件内容 \tn % Row Count 17 (+ 2) % Row 12 \SetRowColor{LightBackground} wc \{fn\} & \seqsplit{统计文件有多少行,多少单词,多少字母} \tn % Row Count 19 (+ 2) % Row 13 \SetRowColor{white} chmod 644 \{fn\} & 修改文件权限 \tn % Row Count 21 (+ 2) % Row 14 \SetRowColor{LightBackground} grep & \seqsplit{匹配文件中字符(串)} \tn % Row Count 23 (+ 2) % Row 15 \SetRowColor{white} stat & 显示文件详细情形 \tn % Row Count 24 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.64 cm} x{5.36 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{输出/输入/重定向}} \tn % Row 0 \SetRowColor{LightBackground} cmd1 | cmd2 & \seqsplit{管道,cmd1的标准输出接到cmd2的标准输入} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \textless{} file & \seqsplit{将文件内容重定向为命令的标准输入} \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \textgreater{} file & \seqsplit{将命令的标准输出重定向到文件,会覆盖文件} \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} \textgreater{}\textgreater{} file & \seqsplit{同上,但追加不覆盖文件} \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} \textless{}\textgreater{} file & \seqsplit{同时使用该文件作为标准输入和标准输出} \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} \textless{}\&- & 关闭标准输入 \tn % Row Count 14 (+ 1) % Row 6 \SetRowColor{LightBackground} \textgreater{}\&- & 关闭标准输出 \tn % Row Count 15 (+ 1) % Row 7 \SetRowColor{white} diff \textless{}(cmd1) \textless{}(cmd2) & \seqsplit{比较两个命令的输出} \tn % Row Count 17 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.16 cm} x{5.84 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{进程管理}} \tn % Row 0 \SetRowColor{LightBackground} ps & 查看当前会话进程 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ps aux & \seqsplit{查看所有进程详细信息} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} kill \{pid\} & 结束进程 \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} kill -9 \{pid\} & 强制结束进程 \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} top & 查看最活跃的进程 \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} \{any\_command\} \& & 在后台运行命令 \tn % Row Count 9 (+ 2) % Row 6 \SetRowColor{LightBackground} CTRL+Z & \seqsplit{将当前进程挂到后台} \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} jobs & 查看所有后台进程 \tn % Row Count 11 (+ 1) % Row 8 \SetRowColor{LightBackground} bg & \seqsplit{查看后台进程,并切换过去} \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} fg & \seqsplit{切换后台进程到前台} \tn % Row Count 14 (+ 1) % Row 10 \SetRowColor{LightBackground} fg \{jobs\} & \seqsplit{切换特定后台进程到前台} \tn % Row Count 16 (+ 2) % Row 11 \SetRowColor{white} disown & \seqsplit{将进程从后台任务列表(job)移除} \tn % Row Count 18 (+ 2) % Row 12 \SetRowColor{LightBackground} wait & \seqsplit{等待所有后台进程任务结束} \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.64 cm} x{5.36 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{目录操作}} \tn % Row 0 \SetRowColor{LightBackground} cd - & 回到之前的目录 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} mkdir \{dirname\} & 创建目录 \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} pushd \{dirname\} & \seqsplit{目录压榨并进入新目录} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} popd & \seqsplit{弹出并进入栈顶的目录} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} dirs -v & 列出当前目录栈 \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.96 cm} x{5.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{SSH/系统信息}} \tn % Row 0 \SetRowColor{LightBackground} ssh user@host & \seqsplit{以用户user登陆到远程主机host} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} scp \{fn\} \seqsplit{user@host:path} & \seqsplit{拷贝文件到远程主机} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} scp \seqsplit{user@host:path} dest & \seqsplit{从远程主机拷贝文件回来} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} uname & 显示系统版本号 \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} uptime & 查看系统启动时间 \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} data & 显示日期 \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} cal & 显示日历 \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} vmstat & \seqsplit{显示内存和CPU使用情况} \tn % Row Count 12 (+ 2) % Row 8 \SetRowColor{LightBackground} vmstat 10 & \seqsplit{每10秒打印一次mem与cpu使用情况} \tn % Row Count 14 (+ 2) % Row 9 \SetRowColor{white} free & \seqsplit{显示内存和交换区使用情况} \tn % Row Count 16 (+ 2) % Row 10 \SetRowColor{LightBackground} wget \{url\} & \seqsplit{下载文件并输出到标准输出(不保存)} \tn % Row Count 18 (+ 2) % Row 11 \SetRowColor{white} sz \{file\} & 发送文件到终端 \tn % Row Count 19 (+ 1) % Row 12 \SetRowColor{LightBackground} rz & \seqsplit{接受终端发送过来的文件} \tn % Row Count 21 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{用户管理}} \tn % Row 0 \SetRowColor{LightBackground} whoami & 显示用户名 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} passwd & 修改密码 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} adduser \{user\} & 添加用户 \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} deluser \{user\} & 删除用户 \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} su & 切换到root用户 \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} su \{user\} & 切换到某用户 \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} sudo \{command\} & 以root权限执行 \tn % Row Count 10 (+ 2) % Row 7 \SetRowColor{white} write \{user\} & 向用户发送信息 \tn % Row Count 11 (+ 1) % Row 8 \SetRowColor{LightBackground} last & \seqsplit{显示最近用户登陆列表} \tn % Row Count 13 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.52 cm} x{4.48 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{cut文本处理}} \tn % Row 0 \SetRowColor{LightBackground} cut -c 1-16 & \seqsplit{截取每行头16个字符} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cut -c 1-16 file & \seqsplit{截取指定文件中每行头16个字符} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} cut -c3- & \seqsplit{截取每行从第3个字符开始到行末尾的内容} \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} cut -d':' -f5 & \seqsplit{截取用冒号分割的第五列内容} \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} cut -d';' -f2,10 & \seqsplit{截取用分号分割的第二和第十列内容} \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} cut -d' ' -f3-7 & \seqsplit{截取空格分隔的3到7列} \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} echo "hello" | cut -c1-3 & 显示hel \tn % Row Count 16 (+ 2) % Row 7 \SetRowColor{white} echo "hello sir" | cut -d' ' -f2 & 显示sir \tn % Row Count 18 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}