Linux 常用操作、基本知识参考手册

来源网站
*All knowledge are coming from this website.

最近开始学习cloud computing这门课,然后老师给的Reference里有这个网站,方便查阅,便总结这个。

常用Command

  1. list(list)

    • list-a: List things in long listing fashion
    • ls-a: List things including "hidden" files (就是以"."开头的,都是Hidden的文件。)
  2. lsblk print block devices by their assigned name (but not RAM)

  3. md5sum (Compute and Check MD5 Message Digest)

  4. dd: Command “dd” stands for (Convert and Copy a file), Can be used to convert and copy a file and most of the times is used to copy an iso file (or any other file) to a USB device (or any other location), thus can be used to make a ‘Bootlable‘ USB Stick.

  5. uname(unix name),check all machine info.

  6. history stands for History (Event) Record, it prints the history of long list of executed commands in terminal.查看历史所有运行的记录,sudo xxx/ sudo xxx/...

  7. sudo(super user do)

  8. mkdir making directory

  9. touch:(Update the access and modification times of each FILE to the current time). touch command creates the file, only if it doesn’t exist. If the file already exists it will update the timestamp and not the contents of the file.(如果文件不存在,则创建文件,否则update the timestamp)

  10. chmod stands for (change file mode bits). chmod changes the file mode (permission) of each given file, folder, script, etc.. according to mode asked for.
    Read (r)=4 Write(w)=2 Execute(x)=1
    rwxr-x--x abc.sh
    Here the root’s permission is rwx (read, write and execute).
    usergroup to which it belongs, is r-x (read and execute only, no write permission) and for world is –x (only execute).
    root@tecmint:~# chmod 777 abc.sh (provide read, write and execute permission to owner, group, and world.)
    root@tecmint:~# chmod 666 abc.sh (only read and write permission to all three.)
    root@tecmint:~# chmod 711 abc.sh(read, write and execute to owner and only execute to group and world.)

  11. chown: (change file owner and group). Every file belongs to a group of user and a owner. 在用ls-l的时候可以看到它的file owner /group,然后你可以更改成你想要的woner,或者group:

    owner and group.png

    change the group.png

  12. apt: stands for (Advanced Package Tool). Apt is an advanced package manager for Debian based system (Ubuntu, Kubuntu, etc.)

  13. tar压缩,解压缩,都是这个。 可以参考:这个链接

    • 创建压缩文件 tar -cvf tecmint-14-09-12.tar /home/tecmint/
    • 创建tar.gz文件 # tar cvzf MyImages-14-09-12.tar.gz /home/MyImages 或者 tar cvzf MyImages-14-09-12.tgz /home/MyImages
    • 解压
      • 解压到当前文件: # tar -xvf public_html-14-09-12.tar
      • 解压到指定文件:# tar -xvf public_html-14-09-12.tar -C /home/public_html/videos/
    • 列出所有文件:# tar -tvf uploadprogress.tar
    • 解压指定文件:# tar -xvf cleanfiles.sh.tar cleanfiles.sh或者tar --extract --file=cleanfiles.sh.tar cleanfiles.sh
  14. cal “cal” (Calendar), it is used to displays calendar of the present month or any other month of any year that is advancing or passed. eg: cal 02 1935 就是打印1935年2月的calendar.

  15. date打印日期,更改日期date --set='14 may 2013 13:57'

  16. cat合并文件 “cat” stands for (Concatenation). Concatenate (join) two or more plain file and/or print contents of a file on standard output.

    • 创建文件:cat > file1然后输入你想要输入的内容,结束之后,按下ctrl+D,回到命令行,然后文件就创建成功了。
    • 浏览文件,你同样可以用cat file1
    • 合并文件,然后命名为新的文件 cat file1 file2 > newfile
  17. cp copy文件cp /home/user/Downloads abc.tar.gz /home/user/Desktop (Return 0 when sucess)

18.mv 移动文件 root@tecmint:~# mv /home/user/Downloads abc.tar.gz /home/user/Desktop (Return 0 when sucess)
* 重命名文件 mv name1 name2就可以重命名成功。

  1. pwd “pwd” (print working directory), prints the current working directory with full path name from terminal. root@tecmint:~# pwd /home/user/Desktop

  2. cd,进入文件夹


常用Command补充

  1. 删除文件rm,删除文件夹rmdir

  2. 帮助文件:man <command>当你想查看某个命令是怎么使用的,你就打这个。

  3. clear,清空当前屏幕

  4. 粘贴(其实这么久了我都不知道如何快捷键粘贴),真正的粘贴是,Ctrl+Shift+V,或者你可以使用shit+insert,最笨的方法就是选择edit,paste。

    Command1.png

    command2.png

    command3.png

    image.png


补充二 输入与输出

  • 输入&输出: stdinstdout
  • 添加文本: (not overwritten): echo xxx(你要添加的内容 >> (你的文件名)
  • 邮件附件用<
    三种情况.png
  • 使用者三个情况看系统解释:
    *find . -name 'my*' 2> error.log便可以存下这个error,然后名字就是error.log,最后就用cat error.log便可查看error的原因了。
  • 复杂情况:


    复杂情况.png

补充三 Linux之间的沟通

  • Ping:Ping <ipaddress>/<www.xxx.com> ,ctrl + c 推出

  • ftp: ftp xx.xxx.xx.xx,输入人账号密码之后就可进行文件传输

    FTP命令.png

    • 进入ftp后,输入dir,然后输入 passive然后就 激活了,就可以正常使用dir命令。
    • 上传 put xxx
  • Telnet: 和windows的远程桌面相似。

  • SSH:securely connect to a remote computer,比telnet更加安全;

    • 需要 证书和Key,才能够访问(所以很安全),访问方式是:SSH username@ip-address or hostname
    • 输入exit就可以退出SSH的连接。

Linux Vi 编辑器

Terminal,高效,简介,如果熟悉命令行操作,简直比GUI界面操作快上很多倍;缺点,需要花时间熟悉命令行。

常见的VI编辑器: Vim, elvis,nvi,nano,vile
其实直接Terminal都可以用vi <文件名>去编辑文件

  • 输入模式(command mode): 'i',然后开始输入东西,输入ESC就退出输入模式
  • 创建文件/编辑文件:vi <NewFileName>/ vi <existFileName>
    VI常用命令.png

    VI常用命令2.png

    VI命令-指针移动.png

    VI命令-保存/退出.png

文本编辑基本上是比较常用的,要很熟悉才行。


Linux Vitural Terminal

多人访问一个服务器的时候,或者说你需要远程控制一台机器,就会涉及到这方面的知识。它的特点是你没办法使用鼠标 Ubuntu系统下,ctrl+alt+F1,输入virtual box 用户名,密码。然后你就可以Login了。不同用户可以登录进去。

  • 常用快捷键:Ctrl+Alt+F(1~6)用户不同用户的切换,输入tty你可以查看你到底是哪个登录进去。
    常用命令1.png

    常用命令2.png
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 151,688评论 1 330
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 64,559评论 1 273
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 101,749评论 0 226
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 42,581评论 0 191
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 50,741评论 3 271
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 39,684评论 1 192
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,122评论 2 292
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 29,847评论 0 182
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 33,441评论 0 228
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 29,939评论 2 232
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,333评论 1 242
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 27,783评论 2 236
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,275评论 3 220
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 25,830评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,444评论 0 180
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 34,553评论 2 249
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 34,618评论 2 249

推荐阅读更多精彩内容