Reference Link
*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