linux—命令汇总

 

pwd                   # 显示当前工作目录
cd /tmp             # cd切换工作目录
pwd
cd ./dir01                      # .当前工作目录
cd ../dir02                     # ..上层工作目录
cd -                              # -前一个工作目录
cd ~                             # ~当前用户的家目录
cd ~   用户名               # 用户的家目录
pwd

mkdir /tmp/sampledir                  #创建名为sampledir的目录
cd /tmp/sampledir
pwd
cd ..
mkdir -p /tmp/dirlevel01/dirlevel0101             # -p创建嵌套目录
pwd
rmdir /sampledir                                            # 删除sampledir目录
cd sampledir
cd /sampledir
rmdir dirlevel01                                            # rmdir只能删除空目录

cd /tmp
ls /etc/passwod                                           # ls列出文件
ls /etc                                                          # 列出目录下的所有文件
ls                                                                 # 列出当前目录下所有文件
ls -a                                                            # 列出所有文件,包括隐藏文件
ls -l                                                             # 以长格式列出文件
ls -al
nano ./hello.sh                                          # nano打开文件
./hello.sh
su - nboocer01                                        # su切换用户
cd /tmp
ls -l
ls -l /tmp
chmod 700 hello.sh                               # chmod修改文件属性
ls -l ./hello.sh
su - root
chown nbcc:stu hello.sh                       # chown修改文件拥有者和从属用户组
chown stu hello.sh
chown :stu hello.sh

cd ~
ls
cp /tmp/file01 ~                             # cp拷贝文件
ls
cp /tmp/file01 ~/file01_bak
ls
cp /tmp/file02 /tmp/file03 /tmp/file04 ~
cp -r /tmp/dir01 ~                                                          # cp -r 拷贝目录
\cp -f /tmp/file02 /tmp/file03 /tmp/file04 ~                     # \cp -f拷贝时强制覆盖所用同名文件
ls -l /tmp/sample.sh ~
cp /tmp/sample.sh ~nbcc
ls -l ~nbcc/sample.sh
cp -p /tmp/sample.sh ~nbcc                                       # cp -p 不改变文件属性。(登录用户对该文件有写权限才能使用该命令)
mv                                                                              # mv移动文件,与cp类似。不加参数。强制覆盖重名文件是mv -f。
mv ./file08 ./file08_rename                                        #  mv用于重命名文件,Linux没有专门的重命名文件命令
ls 
rm                                                                              # rm删除文件
rm ./file01 ./file02
rm -R ./dir01                                                              # rm -R 删除目录
rm -fR ./dir02/                                                            # rm -fR 不询问,直接删除文件
cd /tmp
ls
touch ./empty                                                          # touch 创建空文件
ls
touch ./sample.sh                                                  # sample.sh 为原有文件,则会改变时间戳属性
ls -l ./sample.sh

ls -l /tmp/hello.sh
ln -s /tmp/hello.sh ./hello_slink                             # ln -s 创建链接。为hello.sh创建一个名为hello_slink的符号链接。
ls -l ./hello_slink
rm /tmp/hello.sh
ls -l ./hello_slink
./hello_slink
ls -il #ls -i 列出文件的inode-number
ln                                                                         # ln 创建硬链接
ln /tmp/sample.txt ./sample_hl01
ls -il /tmp/sample.txt ./sample_hl01
ln /tmp/sample.txt ./sample_hl02
ls -il /tmp/sample.txt ./sample_hl01 ./sample_hl02
rm /tmp/sample.txt
ls -il
cat ./sample_hl01 #
cat ./sample_hl02

ls -l /tmp
tar -cf samplefile.tar /tmp/file01 /tmp/file02 /tmp/file03 /tmp/file04 /tmp/file05 #tar 打包文件
ls -l /tmp
tar -cf samp;edir01.tar /tmp/sampledir01 #tar打包目录
ls -l
tar -tf ./samplefile.tar                                                                        # tar -tf查看打包的文件
tar -f ./samplefile.tar --delete tmp/file05                                           # 删除打包文件中的一个文件
tar -f ./samplefile.tar
tar -f ./sampledir01.tar -A ./samplefile.tar                                        # 合并打包文件(后到前中)
tar -tf .sampledir01.tar
tar -f ./sampledir01.tar -r ~/fileA.txt                                                 # 向打包文件添加一个新文件
tar -tf .sampledir01.tar
ls
ls ./sampledir
tar -xf ./sampledir01.tar -C ./sampledir                                          # 解包文件,默认解包到到当前目录,-C解包到指定目录
ls -Rl ./sampledir

ls -l
gzip ./sampledir.tar                                                                       # gzip压缩文件 只能压缩单个文件,不能压缩目录或多个文件,因此常与tar连用
ls -l
gzip -d ./sampledir.tar.gz                                                             # 解压文件
ls -l
gzip -9 samplefile01                                                                   # 压缩比9
gzip samplefile01                                                                       # 默认压缩比6
gzip -1 samplefile01                                                                   # 压缩比1
tar -caf sample.tar.gz /tmp/samplefile01 /tmp/samplefile02 /tmp/samplefile03 #打包时同时压缩
ls -l
tar -xzf sample.tar.gz                                                               # 解包时同时解压缩
ls -l

locate .tar #locate查找文件
updatedb #更新文件数据库
find / -name password #find查找文件,-name文件名
find /bin -type l #-type 根据文件类型查找
date
find /tmp -mtime -3 -ls #在/tmp目录下查找3天之内内容改变过的文件
find /tmp -mtime +7 -ls #在/tmp目录下查找7天前内容改变过的文件
find /tmp -mtime 4 -ls #在/tmp目录下查找4天前那一天内容改变过的文件
find /tmp -size -3k -ls #在/tmp目录下查找小于3k字节的文件
find /tmp -size +100c -ls #在/tmp目录下查找大于100k字节的文件
find /tmp -size 10M -ls #在/tmp目录下查找大小正好为10M字节的文件
find /tmp -user root -ls #在/tmp目录下查找拥有者为root的文件
find /tmp -uid 500 -ls #在/tmp目录下查找拥有者id为500的文件
find /tmp -group stu -ls #在/tmp目录下查找从属于stu用户组的文件
find /tmp -gid 0 -ls #在/tmp目录下查找从属于gid为0的用户组的文件
find /tmp -perm 754 -ls #查找754权限的文件
find /tmp \(-size +lk -a -size -10M -a -mmin -30 -a -type f \) -ls #多个条件查找。-a与,-o或,!非。
find /tmp \(-size +lk -a -size -10M \) -exec rm -rf {} \; #-exec 对查找到的文件进行操作。相同功能-OK,每次执行前都提示

ls /tmp
rm -f /tmp/*.txt # 通配符*,表示任意长度字符串(包括0长度)
ls -l /bin/??sh # 通配符?,表示单个字符串
ls ~
cp /tmp/file[0-9].txt ~ #通配符[],匹配[]内任意单一字符
chmod 700 /tmp/script[a,1,x].sh
ls -l /tmp
rm -rf {jiaoben,script}*.sh #通配符{},
tar -cf file .tar /tmp/file[!0-9].txt #通配符!,取反。

cat /etc/password #cat 查看文件
less /var/log/messages #less 查看文件。 之后键入/root,可以找到root,用n跳转到下一个root处,N跳转到上一个root处,q退出less,回到命令行
head/tail -n 20 /var/log/messages #查看messages文件前/后20行。不跟-n和参数,默认显示前/后10行

 

转载于:https://www.cnblogs.com/Lengjie/p/9590805.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/388624.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

flex 添加右键链接

private var myMenu:ContextMenu;private function setViewerVersion():void{var menuItem:ContextMenuItem new ContextMenuItem("技术支持:中科天宇软件有限公司", true, true);menuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, functio…

jquery数据折叠_通过位折叠缩小大数据

jquery数据折叠Sometimes your dataset is just too large, and you need a way to shrink it down to a reasonable size. I am suffering through this right now as I work on different machine learning techniques for checkers. I could work for over 18 years and buy…

js基础语法

||与&& a && b : 将a, b转换为Boolean类型, 再执行逻辑与, true返回b, false返回aa || b : 将a, b转换为Boolean类型, 再执行逻辑或, true返回a, false返回b转换规则:对象为true非零数字为true非空字符串为true其他为false * 几乎所有语言中||和&&都遵…

新鬼影病毒

今天和明天是最后两天宿舍有空调的日子啦,暑假宿舍没空调啊,悲催T__T 好吧,今天是最精华的部分啦对于鬼影3的分析,剩下的都是浮云啦,alg.exe不准备分析了,能用OD调试的货.分析起来只是时间问题.但是MBR和之后的保护模式的代码就不一样啦同学们,纯静态分析,伤不起啊,各种硬编码,…

php计算单双,PHP中单双号与变量

例子$string "beautiful";$time "winter";$str This is a $string $time morning!;echo $str. "";eval("\$str \"$str\";");echo $str;?>输出:This is a $string $time morning!This is a beautiful win…

Silverlight:Downloader的使用(event篇)

(1)Downloader的使用首先我们看什么是Downloader,就是一个为描述Silverlight plug-in下载功能的集合.Downloader能异步的通过HTTP GET Request下载内容.他是一个能帮助Silverlight下载内容的一个对象,这些下载内容包括(XMAL content,JavaScript content,ZIP packages,Media,ima…

决策树信息熵计算_决策树熵|熵计算

决策树信息熵计算A decision tree is a very important supervised learning technique. It is basically a classification problem. It is a tree-shaped diagram that is used to represent the course of action. It contains the nodes and leaf nodes. it uses these nod…

多亏了这篇文章,我的开发效率远远领先于我的同事

欢迎大家前往腾讯云社区,获取更多腾讯海量技术实践干货哦~ 本文由独木桥先生发表于云社区专栏 介绍 如果您有从Linux服务器上的源代码安装软件的经验,您可能会遇到make实用程序。该工具主要用于自动编译和构建程序。它允许应用程序的作者轻松地布置构建该…

Free SQLSever 2008的书

Introducing SQL Server 2008 http://csna01.libredigital.com/?urss1q2we6这是一本提供自由使用书!我把它翻译,或转送有什么关系!这样的书还是有几本吧,Introducing Linq,Introducting Silverlight,都是啊!嘿嘿。。。…

流式数据分析_流式大数据分析

流式数据分析The recent years have seen a considerable rise in connected devices such as IoT [1] devices, and streaming sensor data. At present there are billions of IoT devices connected to the internet. While you read this article, terabytes and petabytes…

oracle failover 区别,Oracle DG failover 实战

Oracle dataguardfailover实战操作步骤备库:SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH FORCE;SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;SQL> SHUTDOWN IMMEDIATE;SQL> STARTUP;添加临时文件,删除老的临时文…

Jenkins自动化CI CD流水线之8--流水线自动化发布Java项目

一、前提 插件:Maven Integration plugin 环境: maven、tomcat 用的博客系统代码: git clone https://github.com/b3log/solo.git 远端git服务器: [gitgit repos]$ mkdir -p solo [gitgit repos]$ cd solo/ [gitgit solo]$ git --…

oracle数据泵导入很慢,impdp导入效率的问题

内网从一台服务器A导入到另一台服务器B,38G的数据半个多小时才导了一个表。原来B库上是有数据的,是不是因为TABLE_EXISTS_ACTIONREPLACE 导致速度慢了?parallel8也不知道会不会设高了。SQL> show parameter cpuNAME …

BZOJ2597 WC2007剪刀石头布(费用流)

考虑使非剪刀石头布情况尽量少。设第i个人赢了xi场,那么以i作为赢家的非剪刀石头布情况就为xi(xi-1)/2种。那么使Σxi(xi-1)/2尽量小即可。 考虑网络流。将比赛建成一排点,人建成一排点,每场未确定比赛向比赛双方连边,确定比赛向赢…

数据科学还是计算机科学_数据科学101

数据科学还是计算机科学什么是数据科学? (What is data science?) Well, if you have just woken up from a 10-year coma and have no idea what is data science, don’t worry, there’s still time. Many years ago, statisticians had some pretty good ideas…

开机流程与主引导分区(MBR)

由于操作系统会提供所有的硬件并且提供内核功能,因此我们的计算机就能够认识硬盘内的文件系统,并且进一步读取硬盘内的软件文件与执行该软件来完成各项软件的执行目的 问题是你有没有发现,既然操作系统也是软件,那么我的计算机优势…

肤色检测算法 - 基于二次多项式混合模型的肤色检测。

由于CSDN博客和博客园的编辑方面有不一致的地方,导致文中部分图片错位,为不影响浏览效果,建议点击打开链接。 由于能力有限,算法层面的东西自己去创新的很少,很多都是从现有的论文中学习,然后实践的。 本文…

oracle解析儒略日,利用to_char获取当前日期准确的周数!

总的来说周数的算法有两种:算法一:iw算法,每周为星期一到星期日算一周,且每年的第一个星期一为第一周,就拿2014年来说,2014-01-01是星期三,但还是算为今年的第一周,可以简单的用sql函…

密码机

树状数组1 #include<bits/stdc.h>2 using namespace std;3 int x,y,c[200005];4 char str[20];5 int inline read(){6 int x0,f1;7 char chgetchar();8 while(ch<0||ch>9)9 chgetchar(); 10 while(ch>0&&ch<9){ 11 …

js有默认参数的函数加参数_函数参数:默认,关键字和任意

js有默认参数的函数加参数PYTHON开发人员的提示 (TIPS FOR PYTHON DEVELOPERS) Think that you are writing a function that accepts multiple parameters, and there is often a common value for some of these parameters. For instance, you would like to be able to cal…