https://maker.pro/linux/tutorial/basic-linux-commands-for-beginners

  ## 打开终端

  ##   **Ctrl+Alt+T**

## ls 

```C
— Use the "ls" command to know what files are in the directory you are in. You can see all the hidden files by using the command “ls -a”. ls -l 显示文件具体信息

pwd

打印绝对路径

cd

cd — Use the "cd" command to go to a directory 切换到指定文件夹

cd  .. 返回上一级目录

mkdir & rmdir

mkdir & rmdir — Use the mkdir command when you need to create a folder or a directory. For example, if you want to make a directory called “DIY”, then you can type “mkdir DIY”. Remember, as told before, if you want to create a directory named “DIY Hacking”, then you can type “mkdir DIY\ Hacking”. Use rmdir to delete a directory. **But rmdir can only be used to delete an empty directory.** To delete a directory containing files, use rm.
rm -rf 目录名字 一般在脚本.sh用的较多,每次运行时将旧的文件删除,便于新文件的生成 rm -rf ./name
-r 就是向下递归return,管理有多少级目录,一并删除
-f force

rm

rm - Use the rm command to delete files and directories.  Use "rm -r" to delete just the directory. It deletes both the folder and the files it contains when using only the rm command.

##

touch

touch — The touch command is used to create a file. It can be anything, from an empty txt file to an empty zip file. For example, “touch new.txt”.

man & --help

man & --help — To know more about a command and how to use it, use the man command. It shows the manual pages of the command. For example, “man cd” shows the manual pages of the cd command. Typing in the command name and the argument helps it show which ways the command can be used (e.g., cd –help).

cp

cp — Use the cp command to copy files through the command line. It takes two arguments: The first is the location of the file to be copied, the second is where to copy.

mv

mv — Use the mv command to move files through the command line. We can also use the mv command to rename a file. For example, if we want to rename the file “text” to “new”, we can use “mv text new”. It takes the two arguments, just like the cp command.

locate

locate — The locate command is used to locate a file in a Linux system, just like the search command in Windows. This command is useful when you don't know where a file is saved or the actual name of the file. Using the -i argument with the command helps to ignore the case (it doesn't matter if it is uppercase or lowercase). So, if you want a file that has the word “hello”, it gives the list of all the files in your Linux system containing the word "hello" when you type in “locate -i hello”. If you remember two words, you can separate them using an asterisk (*). For example, to locate a file containing the words "hello" and "this", you can use the command “locate -i *hello*this”.

echo

echo — The "echo" command helps us move some data, usually text into a file. For example, if you want to create a new text file or add to an already made text file, you just need to type in, “echo hello, my name is alok >> new.txt”. You do not need to separate the spaces by using the backward slash here, because we put in two triangular brackets when we finish what we need to write.

cat

cat — Use the cat command to display the contents of a file. It is usually used to easily view programs.
查看GPU型号
lspci | grep -i nvidia
查看NVIDIA驱动版本
cat /proc/driver/nvidia/version

nano, vi, jed

— nano and vi are already installed text editors in the Linux command line. The nano command is a good text editor that denotes keywords with color and can recognize most languages. And vi is simpler than nano. You can create a new file or modify a file using this editor. For example, if you need to make a new file named "check.txt", you can create it by using the command “nano check.txt”. You can save your files after editing by using the sequence Ctrl+X, then Y (or N for no). In my experience, using nano for HTML editing doesn't seem as good, because of its color, so I recommend jed text editor. We will come to installing packages soon.

sudo

— A widely used command in the Linux command line, sudo stands for "SuperUser Do". So, if you want any command to be done with administrative or root privileges, you can use the sudo command. For example, if you want to edit a file like viz. alsa-base.conf, which needs root permissions, you can use the command – sudo nano alsa-base.conf. You can enter the root command line using the command “sudo bash”, then type in your user password. You can also use the command “su” to do this, but you need to set a root password before that. For that, you can use the command “sudo passwd”(not misspelled, it is passwd). Then type in the new root password.

df

 — Use the df command to see the available disk space in each of the partitions in your system. You can just type in df in the command line and you can see each mounted partition and their used/available space in % and in KBs. If you want it shown in megabytes, you can use the command “df -m”.

du

— Use du to know the disk usage of a file in your system. If you want to know the disk usage for a particular folder or file in Linux, you can type in the command df and the name of the folder or file. For example, if you want to know the disk space used by the documents folder in Linux, you can use the command “du Documents”. You can also use the command “ls -lah” to view the file sizes of all the files in a folder.

tar

 — Use tar to work with tarballs (or files compressed in a tarball archive) in the Linux command line. It has a long list of uses. It can be used to compress and uncompress different types of tar archives like .tar, .tar.gz, .tar.bz2,etc. It works on the basis of the arguments given to it. For example, "tar -cvf" for creating a .tar archive, -xvf to untar a tar archive, -tvf to list the contents of the archive, etc. Since it is a wide topic, here are some examples of tar commands.

zip, unzip

 — Use zip to compress files into a zip archive, and unzip to extract files from a zip archive.

##

uname

— Use uname to show the information about the system your Linux distro is running. Using the command “uname -a” prints most of the information about the system. This prints the kernel release date, version, processor type, etc.

apt-get

 — Use apt to work with packages in the Linux command line. Use apt-get to install packages. This requires root privileges, so use the sudo command with it. For example, if you want to install the text editor jed (as I mentioned earlier), we can type in the command “sudo apt-get install jed”. Similarly, any packages can be installed like this. It is good to update your repository each time you try to install a new package. You can do that by typing “sudo apt-get update”. You can upgrade the system by typing “sudo apt-get upgrade”. We can also upgrade the distro by typing “sudo apt-get dist-upgrade”. The command “apt-cache search” is used to search for a package. If you want to search for one, you can type in “apt-cache search jed”(this doesn't require root).

chmod

— Use chmod to make a file executable and to change the permissions granted to it in Linux. Imagine you have a python code named numbers.py in your computer. You'll need to run “python numbers.py” every time you need to run it. Instead of that, when you make it executable, you'll just need to run “numbers.py” in the terminal to run the file. To make a file executable, you can use the command “chmod +x numbers.py” in this case. You can use “chmod 755 numbers.py” to give it root permissions or “sudo chmod +x numbers.py” for root executable. Here is some more information about the chmod command.

hostname

— Use hostname to know your name in your host or network. Basically, it displays your hostname and IP address. Just typing “hostname” gives the output. Typing in “hostname -I” gives you your IP address in your network.

##

ping

C— Use ping to check your connection to a server. Wikipedia says, "Ping is a computer network administration software utility used to test the reachability of a host on an Internet Protocol (IP) network". Simply, when you type in, for example, “ping google.com”, it checks if it can connect to the server and come back. It measures this round-trip time and gives you the details about it. The use of this command for simple users like us is to check your internet connection. If it pings the Google server (in this case), you can confirm that your internet connection is active!

wget


The command will attempt to download the resource you supplied and it will automatically detect the file extension.
For example: If you point it to a website, it’ll download an HTML file. If you’re transferring a large file, you can simply log out and the tool will finish the task in the background.

Tips and Tricks for Using Linux Command Line

You can use the clear command to clear the terminal if it gets filled up with too many commands.
TAB can be used to fill up in terminal. For example, You just need to type “cd Doc” and then TAB and the terminal fills the rest up and makes it “cd Documents”.
Ctrl+C can be used to stop any command in terminal safely. If it doesn't stop with that, then Ctrl+Z can be used to force stop it.
You can exit from the terminal by using the exit command.
You can power off or reboot the computer by using the command sudo halt and sudo reboot.

How to Copy Files Between Computers

This command is incredibly useful when working with developer boards like the Raspberry Pi or BeagleBone boards.

scp <local_file> <remote_user>@<remote_machine>:<remote_path>

Use the following syntax to transfer a file from a remote computer to your machine:

scp <remote_user>@<remote_machine>:<remote_path> <local_path>

tee 将终端输出信息保存在log文件里面

python -u train.py 2>&1 | tee train.log

-u参数表示输出形式

2>&1 也就表示将错误重定向到标准输出上

python执行标准输出流,将输出结果不仅输出到屏幕上而且存储到train.log文件中

source

source命令通常用于重新执行刚修改的初始化文件,使之立即生效,而不必注销并重新登录

source命令也叫做一个点命令: .

用法:source filename 等价于 . filename

当多个指令需要依次执行时候,就可以将操作指令写进一个脚本文件,然后source filename.sh即可

wegt

wget(选项)(参数)

-c:继续执行上次终端的任务;

使用wget -c重新启动下载中断的文件,对于我们下载大文件时突然由于网络等原因中断非常有帮助,我们可以继续接着下载而不是重新下载一个文件。需要继续中断的下载时可以使用-c参数。

echo

脚本中比较常见(或者打印新设置的环境变量,看是否设置成功 echo $NAME),用来输出信息到终端

conda包管理器

conda install 包名字 ——安装包

conda remove 包名字 or conda uninstall 包名字 ——卸载包

conda list 显示当前环境下安装的包

conda activate 虚拟环境 激活要进入的虚拟环境

conda deactivate 退出当前的虚拟环境

linux常用操作指令记录的更多相关文章

  1. linux常用操作指令

    Linux常用操作指令: 常用指令 ls        显示文件或目录 -l           列出文件详细信息l(list) -a          列出当前目录下所有文件及目录,包括隐藏的a(a ...

  2. Linux常用操作指令(面试专用)

    Linux:免费开源,多用户多任务,衍生出很多附属版本,例如常用的RedHat... 常用指令 ls        显示文件或目录 -l           列出文件详细信息l(list) -a   ...

  3. linux 常用操作指令(随时更新)

    ls: 查看当前目录下文件列表 -l   列出文件详细信息l(list)  -a   列出当前目录下所有文件及目录,包括隐藏的a(all) mkdir         创建目录 -p         ...

  4. ubuntu部分常用操作指令记录

    # 以ROOT权限打开图形文件管理界面: sudo nautilus # 给某个文件添加可执行权限,例如: sudo chmod +x /usr/lib/jdk/bin/java # 修改某个文件或文 ...

  5. linux常用系统指令

    [linux常用系统指令] 查看内核版本:cat /proc/version 查看发行版本:cat /etc/issue 通过安装lsb的方式查看发行版本: yum provides */lsb_re ...

  6. Linux常用操作练习

    Linux常用操作练习 练习一:安装CentOS 1.设置为1G内存(才有图形界面).10G硬盘 2.分给交换分区2G(4G一下2G,8G-32G分4G-8G) 练习二:安装CentOS迷你版 1.安 ...

  7. linux日常---3、linux常用操作

    linux日常---3.linux常用操作 一.总结 一句话总结: 状态的确是非常之好,享受这种状态. 1.linux删除文件夹和文件? rm -rf *:删文件和文件夹 rm -rf *.*:只能删 ...

  8. Redis数据类型Strings、Lists常用操作指令

    Redis数据类型Strings.Lists常用操作指令 Strings常用操作指令 GET.SET相关操作 # GET 获取键值对 127.0.0.1:6379> get name (nil) ...

  9. Redis集合的常用操作指令

    Redis集合的常用操作指令 Sets常用操作指令 SADD 将指定的元素添加到集合.如果集合中存在该元素,则忽略. 如果集合不存在,会先创建一个集合然后在添加元素. 127.0.0.1:6379&g ...

  10. CentOS + Nginx 的常用操作指令总结

    CentOS + Nginx 的常用操作指令总结 一. 关于CentOS 查看 yum 源是否存在 yum list | grep nginx 如果不存在 或者 不是自己想要的版本 可以自己设置Ngi ...

随机推荐

  1. 网络编程 UDP套接字

    第十二章 UDP套接字 12.1 前言 上一章讲述了TCP通信方式,它是基于流的面向连接的网络通信.UDP是IP协议上的另一种传输协议. TCP和UDP都是端到端的通信协议,都处于TCP/IP网络模型 ...

  2. C++进阶(哈希)

    vector容器补充(下面会用到) 我们都知道vector容器不同于数组,能够进行动态扩容,其底层原理:所谓动态扩容,并不是在原空间之后接续新空间,因为无法保证原空间之后尚有可配置的空间.而是以原大小 ...

  3. 为什么NoSQL数据库这么受欢迎?

    大数据时代,NoSQL数据库是企业构建数据能力的核心工具之一.近期,在2022腾讯全球数字生态大会NoSQL数据库专场上,腾讯云发布了多项NoSQL产品能力升级,并重点讲解了其背后的自研技术要点及实现 ...

  4. 就聊聊不少小IT公司的技术总监

    本文想告诉大家如下两个观点. 1 很多IT小公司的技术总监,论能力其实也就是相当于大公司的高级程序员. 2 程序员在职业发展过程中,绝对应该优先考虑进大厂或好公司.如果仅仅停留在小公司,由于小公司可能 ...

  5. [OpenCV实战]1 基于深度学习识别人脸性别和年龄

    目录 1基于CNN的性别分类建模原理 1.1 人脸识别 1.2 性别预测 1.3 年龄预测 1.4 结果 2 代码 参考 本教程中,我们将讨论应用于面部的深层学习的有趣应用.我们将估计年龄,并从单个图 ...

  6. 更改json节点key

    json节点key更改,给朋友写的小tool,顺便记录一下 单个指定 每一个需要修改的key,都需要指定 /** * 需要转义的key对象 * 原key: 新key */ const jsonKeys ...

  7. 【大型软件开发】浅谈大型Qt软件开发(一)开发前的准备——在着手开发之前,我们要做些什么?

    前言 最近我们项目部的核心产品正在进行重构,然后又是年底了,除了开发工作之外项目并不紧急,加上加班时间混不够了....所以就忙里偷闲把整个项目的开发思路聊一下,以供参考. 鉴于接下来的一年我要操刀这个 ...

  8. 《Effective C++》再次探索traits技法

    首先介绍C++标准程序库中的五种迭代器,关于这个可以看我的另一个笔记:http://blog.csdn.net/m0_37316917/article/details/70053513. 对于这五种分 ...

  9. Ubuntu 22.04 显示检测到窗口系统采用wayland协议

    解决方法 sudo vim /etc/gdm3/custom.conf #WaylandEnable=false 的注释井号去掉 sudo service gdm3 restart 参考资料 http ...

  10. P6327 区间加区间sin和 题解

    P6327 区间加区间sin和 题解 题目描述 给出一个长度为 \(n\) 的整数序列 \(a_1,a_2,\ldots,a_n\),进行 \(m\) 次操作,操作分为两类. 操作 \(1\):给出 ...