linux终端移动文件命令_如何从Linux终端管理文件:您需要知道的11个命令

linux终端移动文件命令

linux终端移动文件命令

To use the Linux terminal like a pro, you’ll need to know the basics of managing files and navigating directories. True to the Unix philosophy, each command does one thing and does it well.

要像专业人士一样使用Linux终端,您需要了解管理文件和浏览目录的基础知识。 忠实于Unix哲学,每个命令都做一件事并且做得很好。

Midnight Commander, a full-featured file manager for the Linux terminal, acts as a powerful front end to all these commands.

Midnight Commander是Linux终端的功能齐全的文件管理器,是所有这些命令的强大前端。

ls –列出文件 (ls – List Files)

The ls command lists the files in a directory. By default, ls lists files in the current directory.

ls命令列出目录中的文件。 缺省情况下,ls列出当前目录中的文件。

You can also list files recursively — that is, list all files in directories inside the current directory — with ls -R.

您还可以使用ls -R递归列出文件(即,列出当前目录内目录中的所有文件)。

ls can also list files in another directory if you specify the directory. For example, ls /home will list all files in the /home directory.

如果您指定目录,ls也可以列出另一个目录中的文件。 例如, ls / home将列出/ home目录中的所有文件。

cd –更改目录 (cd – Change Directory)

The cd command changes to another directory. For example, cd Desktop will take you to your Desktop directory if you’re starting from your home directory.

cd命令更改到另一个目录。 例如,如果您从主目录开始, cd Desktop会将您带到您的Desktop目录。

You can also specify a full path to a directory, such as cd /usr/share to go to the /usr/share directory on the file system.

您还可以指定目录的完整路径,例如cd / usr / share,以转到文件系统上的/ usr / share目录。

cd .. will take you up a directory.

cd ..将带您进入目录。

rm –删除文件 (rm – Remove Files)

The rm command removes files. Be careful with this command — rm doesn’t ask you for confirmation.

rm命令删除文件。 请谨慎使用此命令-rm不会要求您确认。

For example, rm file would delete the file named “file” in the current directory. Like with other commands, you could also specify a full path to a file: rm /path/to/file would delete the file at /path/to/file on your file system.

例如, rm file会删除当前目录中名为“ file”的文件。 与其他命令一样,您也可以指定文件的完整路径: rm / path / to / file会删除文件系统上/ path / to / file处的文件。

rmdir –删除目录 (rmdir – Remove Directories)

The rmdir command removes an empty directory. rmdir directory would delete the directory named “directory” in the current directory.

rmdir命令除去一个空目录。 rmdir目录将删除当前目录中名为“ directory”的目录。

If the directory isn’t empty, you can use a recursive rm command to remove the directory and all files in it. rm -r directory would delete the directory named “directory” and all files in it. This is a dangerous command that could easily delete a lot of important files, so be careful when using it. It won’t ask for confirmation.

如果目录不为空,则可以使用递归rm命令删除目录及其中的所有文件。 rm -r目录将删除名为“ directory”的目录及其中的所有文件。 这是一个危险的命令,很容易删除很多重要文件,因此在使用时要小心。 它不会要求确认。

mv –移动文件 (mv – Move Files)

The mv command moves a file to a new location. This is also the command you’ll use to rename files. For example, mv file newfile would take the file named “file” in the current directory and move it to the file named “newfile” in the current directory — renaming it, in other words.

mv命令将文件移动到新位置。 这也是用于重命名文件的命令。 例如, mv文件newfile将采用当前目录中名为“ file”的文件,并将其移至当前目录中名为“ newfile”的文件,即重命名。

Like with other commands, you can include full paths to move files to or from other directories. For example, the following command would take the file named “file” in the current directory and place it in the /home/howtogeek folder:

与其他命令一样,您可以包含将文件移入或移出其他目录的完整路径。 例如,以下命令将在当前目录中获取名为“ file”的文件,并将其放置在/ home / howtogeek文件夹中:

mv file /home/howtogeek

mv文件/ home / howtogeek

cp –复制文件 (cp – Copy Files)

The cp command works the same way as the mv command, except it copies the original files instead of moving them.

cp命令与mv命令的工作方式相同,除了它复制原始文件而不是移动它们。

You can also do a recursive copy with cp -r. This copies a directory and all files inside it to a new location. For example, the following command places a copy of the /home/howtogeek/Downloads directory into the /home/chris directory:

您也可以使用cp -r进行递归复制。 这会将目录及其中的所有文件复制到新位置。 例如,以下命令将/ home / howtogeek / Downloads目录的副本放入/ home / chris目录:

cp -r /home/howtogeek/Downloads /home/chris

cp -r / home / howtogeek /下载/ home / chris

mkdir –制作目录 (mkdir – Make Directories)

The mkdir command makes a new directory. mkdir example will make a directory with the name “example” in the current directory.

mkdir命令创建一个新目录。 mkdir示例将在当前目录中创建一个名为“ example”的目录。

ln –创建链接 (ln – Create Links)

The ln command creates links. The most commonly used type of link is probably the symbolic link, which you can create with ln -s.

ln命令创建链接。 最常用的链接类型可能是符号链接,可以使用ln -s创建。

For example, the following command creates a link to our Downloads folder on our Desktop:

例如,以下命令将创建一个指向我们桌面上“下载”文件夹的链接:

ln -s /home/howtogeek/Downloads /home/howtogeek/Desktop

ln -s / home / howtogeek /下载/ home / howtogeek /台式机

Check out our article on symbolic links for more information.

请查看我们有关符号链接文章,以获取更多信息。

chmod –更改权限 (chmod – Change Permissions)

chmod changes a file’s permissions. For example, chmod +x script.sh would add executable permissions to the file named script.sh in the current folder. chmod -x script.sh would remove executable permissions from that file.

chmod更改文件的权限。 例如, chmod + x script.sh会将可执行权限添加到当前文件夹中名为script.sh的文件中。 chmod -x script.sh将从该文件中删除可执行权限。

Linux file permissions can be a bit complicated. Check out our guide to Linux file permissions for more in-depth information.

Linux文件权限可能有点复杂。 查阅我们的Linux文件权限指南,以获取更深入的信息。

触摸–创建空文件 (touch – Create Empty Files)

The touch command creates an empty file. For example, touch example creates an empty file named “example” in the current directory.

touch命令创建一个空文件。 例如, touch example在当前目录中创建一个名为“ example”的空文件。

mc –完整文件管理器 (mc – A Full File Manager)

Midnight Commander is one of many fully featured file managers you can use from the Linux terminal. It isn’t installed by default on most distributions; here’s the command you’ll need to install it on Ubuntu:

Midnight Commander是可以从Linux终端使用的许多功能齐全的文件管理器之一。 默认情况下,大多数发行版中未安装该软件。 这是您需要在Ubuntu上安装它的命令:

sudo apt-get install mc

须藤apt-get install mc

Once it’s installed, just run the mc command to launch it.

安装完成后,只需运行mc命令即可启动它。

Use the arrow keys to select files and the Tab key to switch between panes. Press Alt-1 to see the help screen or Alt-2 to see the menu.

使用箭头键选择文件,然后使用Tab键在窗格之间切换。 按Alt-1查看帮助屏幕,或按Alt-2查看菜单。

You can also use the mouse in Midnight Commander if your terminal environment has mouse support.

如果您的终端环境支持鼠标,则也可以在Midnight Commander中使用鼠标。



Remember that you’ll need to run these commands with root permissions if you’re modifying a system directory. On Ubuntu, add sudo to the beginning of commands you want to run with root permissions.

请记住,如果要修改系统目录,则需要以root权限运行这些命令。 在Ubuntu上,将sudo添加到要以root权限运行的命令的开头。

翻译自: https://www.howtogeek.com/107808/how-to-manage-files-from-the-linux-terminal-11-commands-you-need-to-know/

linux终端移动文件命令

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值