知识就是砖,哪里需要哪里搬
linux新手,这里记录下新手过程中的一些最简单基础的问题, update anytime.
Ubuntu LTS 版本中LTS的意思
LTS means Long Term Supports
参考链接: Ubuntu LTS 是什么?
linux中经常看到.rc文件,如.bashrc,.vimrc 这些rc代表什么
在Linux中,最为常用的缩略语也许是“rc”,它是“runcomm”的缩写――即名词“run command”(运行命令)的简写。rc”是任何脚本类文件的后缀,这些脚本通常在程序的启动阶段被调用,通常是Linux系统启动时。如/etc/rs是Linux启动的主脚本,而.bashrc是当Linux的bash shell启动后所运行的脚本。
.bashrc的前缀“.”是一个命名标准,它被设计用来在用户文件中隐藏那些用户指定的特殊文件;“ls”命令默认情况下不会列出此类文件,“rm”默认情况下也不会删除它们。许多程序在启动时,都需要“rc”后缀的初始文件或配置文件,这对于Unix的文件系统视图来说,没有什么神秘的。
参考链接:Linux中的.rc文件介绍
chmod命令
首先查看文件属性
***@**Sever:~/test$ ls -la
total 56
drwxrwxr-x 2 username group_name 4096 Jun 20 20:54 .
drwx------ 7 username group_name 4096 Jun 20 20:54 ..
-rw-rw-r-- 1 username group_name 0 Jun 20 20:54 1.txt
-rw-rw-r-- 1 username group_name 0 Jun 20 20:54 2.txt
-rw-rw-r-- 1 username group_name 0 Jun 20 20:54 3.txt
-rw-rw-r-- 1 username group_name 0 Jun 20 20:54 4.txt
-rw-rw-r-- 1 username group_name 0 Jun 20 20:54 5.txt
-rw-rw-r-- 1 username group_name 0 Jun 20 20:54 6.txt
第一项:文件权限
drwxrwxr-x
结构类型为:
文件类型(1)文件所有者权限(3)文件所属用户组权限(3)其他人对此文件的权限(3)
其中文件类型:
d
directory
表明为目录-
表明为目录l
linkfile
表明为连接文件b
表明为设备文件中可供存储的接口设备c
表明为设备文件中的串行端口设备,如键盘,鼠标等
后面的三个为权限分配,三位顺次表示为读,写,执行
权限。取值如下;
r
read 权限w
write 权限x
execute 权限-
不存在对应的此位置上应有的权限
chmod
命令的功能就是改变权限
方式1:数字方式
user_name@host_name:~/test$ ls -l 1.txt |cut -d ' ' -f1
-rw-rw-r--
user_name@host_name:~/test$ chmod 777 1.txt
user_name@host_name:~/test$ ls -l 1.txt |cut -d ' ' -f1
-rwxrwxrwx
权限分配777=(111)(111)(111)
,1代表对应位置的权限存在
若分配权限为三个身份均为只可读,应该为(100)(100)(100)=444
user_name@host_name:~/test$ ls -l 1.txt
-rwxrwxrwx 1 user_name group_name 0 Jun 20 20:54 1.txt
user_name@host_name:~/test$ chmod 444 1.txt
user_name@host_name:~/test$ ls -l 1.txt
-r--r--r-- 1 lier lier 0 Jun 20 20:54 1.txt
方式2:文字分配
身份(默认为a)
* a all
* g group
* u user
* o others
用户添加执行权限
chmod u+x 1.txt
用户添加写权限
chmod u+w 1.txt
用户同时添加读执行权限
chmod u+rw 1.txt
用户添加所有权限
chmod u+rwx 1.txt
不需要一定按照读写执行顺序进行添加或修改。下面的-,=也一样
chmod u+rwx 1.txt = chmod u+xwr 1.txt
* 将上面命令的u改为g或者o就是对对应的身份设置权限
chmod g+x 1.txt
chmod g+w 1.txt
chmod g+wr 1.txt
放过o了,也是同样的
* 如果对三个身份(创建文件的用户,组,其他人)同时设定,身份改为a即可。
chmod a+x 1.txt
* 去掉权限用-号。
chmod a-x 1.txt
* 想自定义设置,则用=号
chmod u=r 1.txt 代表 chmod u=r--
设置权限不仅是可以为文件设置,也可以对整个目录设置
查看系统内存大小
***@*** ~$free -h
total used free shared buffers cached
Mem: 2.0G 1.9G 78M 796K 8.1M 42M
-/+ buffers/cache: 1.8G 128M
Swap: 0B 0B 0B
帮助请查看man free
- tar命令
Examples:
tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely.
tar -xf archive.tar # Extract all files from archive.tar.
Main operation mode:
-c, --create create a new archive
-r, --append append files to the end of an archive
-t, --list list the contents of an archive
-x, --extract, --get extract files from an archive
-f, --file=ARCHIVE use archive file or device ARCHIVE 【alway last param】
-z, --gzip, --gunzip, --ungzip filter the archive through gzip
-v, --verbose verbosely list files processed
之前在用,不过一直是有些死记硬背。现在整理一下,以上重要参数都是通过tar --help |less
得到的。
打包就是打包,没有压缩,压缩参数是
j(*.tar.bz2),z(*.tar.gz)
,一般而言,压缩包都是先打包,后压缩。因此涉及到压缩解压时,用上这个主流参数。参数
c(lower)
或者x
的存在 (c-Create, x-eXtract
)
压缩命令首先是个双重命令,能压缩就能解压,因此必须设定参数说明是用于解压还是压缩f参数 (File-name)
无论是解压缩还是压缩,都少不了这个参数,当然啦,这是目的文件啊。
记住,f参数一定是所有的option中的最后一个参数,紧跟文件名。
ubuntu
默认的编辑器是nano
,用不习惯,设置成vim
的命令为:
在~下新建.barchrc文件
export EDITOR=vim
想要立即生效,使用source .barchrc
命令即可。
或者使用select-editor
命令,选择vim
即可