\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{wy371tt1} \pdfinfo{ /Title (linux.pdf) /Creator (Cheatography) /Author (wy371tt1) /Subject (Linux 中文小抄 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}{0A2EA3} \definecolor{LightBackground}{HTML}{EFF1F9} \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 中文小抄 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{wy371tt1} via \textcolor{DarkBackground}{\uline{cheatography.com/28042/cs/8261/}}} \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}wy371tt1 \\ \uline{cheatography.com/wy371tt1} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 21st May, 2016.\\ 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 -al & 详细目录列表 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} cd & 改变路径 \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} cd .. & 上一层目录 \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} pwd & 当前路径 \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} mkdir dir & 创建目录 \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} rm file & 删除文件 \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} rm -r dir & 删除 dir 目录 \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} rm -f file & 强制删除文件 \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} rm -rf dir & 强制删除 dir 目录 \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} cp file1 file2 & 拷贝文件 \tn % Row Count 12 (+ 2) % Row 11 \SetRowColor{white} cp -r dir1 dir2 & 拷贝目录,如果 dir2 不存在,创建它 \tn % Row Count 14 (+ 2) % Row 12 \SetRowColor{LightBackground} mv file1 file2 & \seqsplit{重命名或者移动文件,如果} file2 \seqsplit{是一个目录,则移动} file1 至 file2 目录 \tn % Row Count 18 (+ 4) % Row 13 \SetRowColor{white} ln -s file link & 创建硬链接 \tn % Row Count 20 (+ 2) % Row 14 \SetRowColor{LightBackground} touch file & 创建或者更新文件 \tn % Row Count 21 (+ 1) % Row 15 \SetRowColor{white} cat \textgreater{} file & 输入文件 \tn % Row Count 22 (+ 1) % Row 16 \SetRowColor{LightBackground} more file & 输出文件内容 \tn % Row Count 23 (+ 1) % Row 17 \SetRowColor{white} head file & 输出前 10 行内容 \tn % Row Count 24 (+ 1) % Row 18 \SetRowColor{LightBackground} tail file & 输出后 10 行内容 \tn % Row Count 25 (+ 1) % Row 19 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{tail -f file} \tn % Row Count 26 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.48 cm} x{5.52 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} top & 显示所有进程 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} pgrep firefox & 返回 firefox pid \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} pgrep -u root sshd & \seqsplit{显示进程名为sshd、所有者为root的进程} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} kill pid & 根据 pid 杀死进程 \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} killall proc & 杀死 proc* 开头的所有进程 \tn % Row Count 9 (+ 2) % Row 6 \SetRowColor{LightBackground} bg & 列出后台任务 \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} fg & 最近 job 提前 \tn % Row Count 11 (+ 1) % Row 8 \SetRowColor{LightBackground} fg n & job n 提前 \tn % Row Count 12 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{sudo apt-get install htop} \tn % Row Count 13 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{web}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{nginx}} \newline sudo apt-get install nginx \newline sudo service nginx restart \newline 或者 \newline sudo /etc/init.d/nginx start \newline sudo /etc/init.d/nginx stop \newline sudo /etc/init.d/nginx restart \newline \newline {\bf{PHP fpm}} \newline sudo apt-get install php5-fpm \newline sudo service php5-fpm start \newline sudo service php5-fpm stop \newline 或者 \newline sudo /etc/init.d/php5-fpm restart \newline sudo /etc/init.d/php-fastcgi restart \newline \newline {\bf{mysql}} \newline \newline sudo /etc/init.d/mysql start \newline sudo /etc/init.d/mysql stop \newline sudo /etc/init.d/mysql restart} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} p{0.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{网络}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{ifconfig} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{ifup} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{ifdown} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{文件权限}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{chmod octal file}} - 改变文件权限 \newline * 4 - 读(r) \newline * 2 - 写(w) \newline * 1 - 执行(x) \newline \newline 例子: \newline chmod 777 读,写,执行 \newline chomd 755 \seqsplit{文件拥有者读写执行}, 用户组读和执行} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.96 cm} x{3.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{压缩与解压缩}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{tar cf file.tar files}} & \seqsplit{打包文件到} file.tar \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{tar xf file.tar}} & 解包 file.tar \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{tar czf file.tar.gz files}} & 压缩 gzip 包 \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} {\bf{tar xzf file.tar.gz}} & 解药 gzip 包 \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{tar cjf file.tar.bz2 files}} & 压缩 Bzip2 包 \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} {\bf{tar xjf file.tar.bz2}} & 解压 Bzip2 包 \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{gzip file}} & 压缩 file 到 file.gz \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} {\bf{gzip -d file.gz}} & 解压 file.gz 到 file \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{zip FileName.zip -r DirName}} & zip \seqsplit{压缩整个文件夹} \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} {\bf{unzip -d DirName snow.zip}} & zip 解压 \tn % Row Count 18 (+ 2) % Row 10 \SetRowColor{LightBackground} {\bf{sudo apt-get install p7zip-full}} & 安装 7z \tn % Row Count 20 (+ 2) % Row 11 \SetRowColor{white} {\bf{7za a -t7z -r Mytest.7z /opt/phpMyAdmin-3.3.8.1-all-languages/}}* & 7z 压缩 \tn % Row Count 23 (+ 3) % Row 12 \SetRowColor{LightBackground} {\bf{7z x emp-master.7z -r -o./emp }} & 7z 解压 \tn % Row Count 25 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{1.44 cm} x{6.56 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{ssh}} \tn % Row 0 \SetRowColor{LightBackground} su - & 切换 root 账户 \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{备份}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{rsync}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{1.04 cm} x{6.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{vim}} \tn % Row 0 \SetRowColor{LightBackground} :q! & 未保存强制退出 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} :wq & 保存退出 \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{安装}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{从源码编译安装}} \newline ./configure \newline make \newline make install \newline {\bf{sudo apt-get install mysql}} ubuntu 安装包} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}