当前位置: 首页 > 工具软件 > Journey > 使用案例 >

linux-journey

谭仰岳
2023-12-01

title: linux command
tags: nonetag
categories:

  • linux
    date: 2021-04-21 22:36:40

linux command

command line

shell

  • let’s start with a siple command, echo. The command just prints out the arguments to the display.
echo hello,world!

pwd (print working directory)

pwd

cd (change directory)

cd /etc/test
cd test2
  • . ( current directory)
  • … (parent directory)
  • ~ (home directory)
  • - (previous directory)

ls (list directories)

ls 
ls /home
ls -a   show all of the files include the files which are hidden.
ls -l   l means long, this command will show the files with their detile.
ls -la  show all the files with their detile.
ls -R   recursively list directory contents.
ls -r   reverse order while sorting.
ls -t   sort by modification time, newest first.

touch (create a filw)

  • touch allows you to create new empty files.
touch myfile
  • touch is also used to change timestamps on existing files and directories.
touch myfile
touch mydirectory

file (show the type of the file’s contents)

file myfile

cat (show the content of files)

cat file1 file2

less (show less of a file)

  • if you are viewing text files larger than a simple output.(which means it is too big to view on your screen.) you can use less to open it, that can make it easy to view the file.
wget linuxqq_2.0.0-b2-1089_x86_64.sh
mv linuxqq_2.0.0-b2-1089_x86_64.sh qq
less qq
  • the text is displayed in a paged manner, so you can navigate through a text file page by page.

q quit out of less and back to your shell
Page up, Page down, up and down Navigate.
g move to the beginning of the text file
G move to the end of the file
h help
/search search the content behind /

less qq
/qq

history

history   show commands you have typed
ctrl-R 	  
clear 	  clear the screen

cp (copy)

cp myfile /home/files
cp *.jpg /home/jpgs
cp -r directoryone/ /home/document   copy the directory
cp -i my file /home/files   prompt you before overwriting a same-name-file.

mv (move)

  • rename file or directory
mv a b
mv directory1 directory2
  • move files and directories to somewhere
mv a b directory1 directory2 /home
  • wanna a prompt
mv -i directory1 directory2
  • make a backup of the file which is going to be overwritten.
mv b a
the previous file a will be back up and renamed as ~a

mkdir (make a directory)

mkdir one two
  • wanna to create subdirectories?
mkdir -p one/one two/tow

rm (remove)

  • delete a file. the file being deleted will not been pushing into a trash can, so be careful about rm.
rm filea
  • force to delete
rm -f filea
  • wanna a prompt
rm -i filea
  • delete directories
rm -r directory 
or 
rmdir directory

find

find /home -name qq
  • find a directory
find /home -type d -name mydirectory

help

help echo
echo --help

man

man ls

whatis (briefly describe a file)

whatis cat

alias

  • set a alias for a command. the alias are saved in ~/.bashrc
alias foobar='ls la'
  • unlias
unalias foobar

exit

  • exit the shell
exit
or 
logout

以下信息来源于 linux tools quick tutorial

命令帮助

  • 简要说明命令的作用
whatis [command]

  • 正则匹配
whatis -w "m*"

  • 详细说明
info [command]
man [command]

  • 查看路径
which [command]
  • 查看程序的搜索路径,当系统中安装了一个软件的多个版本的话,这个命令可以帮助确定版本。
whereis [command]

文件与目录管理

创建和删除

mkdir
touch 
rm
mv 
cp

目录切换

pwd
cd -  #切换到上一个工作目录
cd ~  #回到home目录
cd ../

查找目录与文件

磁盘操作

dd

if=file #read from file instead of stdin
of-file write to file instead of stdout
by=bytes #read and write bytes bytes at a time (指定块大小)
count=blocks #copy only blocks input blocks 指定块数量
seek=blocks #把块输出到文件时指定要跳过的几块
conv=convs #指定追加数据时的操作 notrunc 是不打断文件。
dd if=mbr.bin of=hd60M.hd bs=512 count=1 seek=0 conv=notrunc

 类似资料: