Python Learning record--ubuntu (i) basic configuration, shortcut keys, and file Operations Command line

Source: Internet
Author: User

1. Common ways to get help:

(1)-H

(2)--help

(3) Man

The man chapter finds information #用于查询某指令在某章节中的帮助信息

Man-f #精确查找

Man-k #模糊查找

(4) Info

2. Install the software using the command line:

Apt-cache Search Package #查找软件包并安装

Apt-cache Show Package #获取安装包的详细信息

Apt-get Update/install/remove/purge (Delete cleaner) package

/etc/apt/sources.list #设置软件包的获取来源

3. Set the system time/time zone and get the calendar:

(1) Date:

Date #显示当前日期

Date formatting:

%Y year%m Month (01..12)%d day of month (01)

%H Hour (00..23)%I Hour (01..12)%M minute (00..59)%s second (00..60)

Date + "%y%m%d%h%m%s" 20160824 223856

Date + "%y-%m-%d%h:%m:%s" 2016-08-24 22:39:07

Date-s #设置当前时间, only root privileges can be set, others can only be viewed.

Date-s 20061010 #设置成20061010, this will set the specific time to empty 00:00:00

Date-s 12:23:23 #设置具体时间, no changes are made to the date date-s "12:12:23 2006-10-10″//so you can set the whole time

  NOTE: After you reset the time, you need to poke the time out of the hardware clock. The method is as follows: Hwclock-w

(2) Tzselect

(3) Cal:

Cal: Calendar

CAL-Y: Current year's annual calendar

Cal year: Annual calendar for the corresponding year

4. Two ways to change a user's password:

(1) passwd #更改当前用户的密码

(2) sudo passwd username #更改指定用户名下的密码, requires administrator,sudo is used to get administrative privileges

5. Common shortcut keys and commands in the command line:

(1) Ctrl + C #结束在命令行中的程序

(2) Tab key #快速补全, press two times to display the current directory file

(3)ctrl+l #清屏

(4) Ctrl+u #清除当前光标位置以前的内容

(5) Ctrl+k #清除当前光标位置以后的内容

(6) Ctrl+w #清除光标左侧的字段至前一个空格处

(7) Ctrl+y #撤销删除操作

(8) Ctrl + A #光标移动到命令行开始处

(9) Ctrl+e #光标移动到命令行末尾

(ctrl+r) #将自动在命令历史缓存中搜索后面输入的内容

(one) Ctrl+d #快速关闭当前终端

(reboot) #重启

() Shutdown #关机

Shutdown-r now #立即重启

Shutdown-r +5 #5分钟后重启

Shutdown-r #在12点重启

Shutdown-h now #立即关机

Shutdown-h +5 #5分钟后关机

Shutdown-h +5 "This system would shutdown in 5 minutes" #带用户提示

Shutdown-h #在12点关机

Shutdown-c #取消关机操作

cd+ address #更改目录至制定地址, such as Cd/home

  Cd.. #返回当前目录的上一级目录

cd-#返回到当前目录之前打开的目录

CD #回根目录

PWD #查看当目录

Touch file name #将文件时间修改成当前时间, such as the time to consolidate multiple files

(+)cat file name #查看文件内容

Use of 6.LS instructions:

(1) ls-a #查看当前目录下所有文件, if the document is in front of the hidden file ; Represents the current directory and parent directory, respectively

(2) LS #查看当前目录下可见的文件

(3) Ls-l #显示所有文件及详细信息

The format is:

File types (-for normal files, d for catalog files, b for block device files, c for character device files, L for link files (e.g. shortcuts), p for pipe files, s for socket files)

For example:-rwxrwxrwx,-is a file type, R is readable, W is writable, X is executable, 3 groups, respectively, user, user group, other people's file operation permissions

When you execute a file, the user must have X permission on the file.

Digital

Owner

User groups belonging to

File size (default is bytes, LS-LH can be changed to KB, directory default is 4096 bytes)

Date Modified

Filename

(4) Ls-lt #附加以时间排降序 (if R is added after T, can be changed to ascending)

(5) Ls-r #遍历所有文件目录

7.mkdir for creating directories:

mkdir Directory name #创建目录

Mkdir-p Directory name 1/directory Name 2/directory name 3 #创建多层目录

8. Delete files ( Use caution, easy to trigger program crashes ):

RM file name #只能删除文件, but cannot delete directory

Rm-i file name #会出现提示

Rm-f file name #强制删除

RM-RF Directory name #强制删除目录

9. Move or rename files/directories:

MV File/directory name new File/directory name #重命名文件/directory

MV FileName Directory name #将文件移至目录下

MV File/directory name. #移动至当前目录

10. Copy the file:

CP file name new file name #在当前目录复制文件并重新命名

CP Directory name/new directory name # Note Directory replication to add/

CP -a filename a new file name #复制文件 and retains the original permission and owner

11. View file Information:

Stat file name

12. Program Writing terminal gedit:

Write #! at the beginning of the file /usr/bin/env Python3 #用于指定解释器为python3, which specifies that files can be executed in./File name mode later

Python Learning record--ubuntu (i) basic configuration, shortcut keys, and file Operations Command line

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.