Linux常用命令行总汇(1)

时间:2022-09-08 17:39:11
1、打开终端
方法:<Ctrl>+<Alt>+t
显示:wyx@wys-pc:~$
2、查看当前目录
方法:ls
显示:
Desktop Downloads hello.c Pictures Templates Videos
Documents examples.desktop Music Public test
3、查看根目录
方法:cd /
ls
显示:
bin dev initrd.img lib64 mnt proc sbin sys var
boot etc initrd.img.old lost+found my_space root snap tmp vmlinuz
cdrom home lib media opt run srv usr vmlinuz.old
4、返回当前目录
方法:cd ~
显示:
5、进入home目录,查看用户名
说明:home目录存放系统中所有用户的主目录,主目录的名字就是用户名。
Home目录不在~目录下,而在/目录下,所以要先进入/目录
方法:cd /
cd home/
ls
显示:lost+found wyx
6、进入用户主目录
方法:使用不带任何参数的cd命令可以进入用户主目录。
cd
ls
显示:Desktop Downloads hello.c Pictures Templates Videos
Documents examples.desktop Music Public test
7、查看/etc目录
这个目录存放着系统以及大部分应用软件的配置文件。
方法:cd /etc/
ls
或者ls /etc/
显示:acpi hosts printcap
adduser.conf hosts.allow profile
alternatives hosts.deny profile.d
anacrontab hp protocols
apg.conf ifplugd pulse
apm iftab python
apparmor ImageMagick-6 python2.7
apparmor.d init python3
apport init.d python3.5
appstream.conf initramfs-tools rc0.d
apt inputrc rc1.d
aptdaemon insserv rc2.d
at-spi2 insserv.conf rc3.d
avahi insserv.conf.d rc4.d
bash.bashrc iproute2 rc5.d
bash_completion issue rc6.d
bash_completion.d issue.net rc.local
bindresvport.blacklist java-9-openjdk rcS.d
binfmt.d kbd resolvconf
bluetooth kernel resolv.conf
bonobo-activation kernel-img.conf rmt
brlapi.key kerneloops.conf rpc
brltty ldap rsyslog.conf
brltty.conf ld.so.cache rsyslog.d
ca-certificates ld.so.conf sane.d
ca-certificates.conf ld.so.conf.d securetty
calendar legal security
chatscripts libao.conf selinux
compizconfig libaudit.conf sensors3.conf
console-setup libnl-3 sensors.d
cracklib libpaper.d services
cron.d libreoffice sgml
cron.daily lightdm shadow
cron.hourly lintianrc shadow-
cron.monthly locale.alias shells
crontab locale.gen signond.conf
cron.weekly localtime signon-ui
cups logcheck skel
cupshelpers login.defs sound
dbus-1 logrotate.conf speech-dispatcher
dconf logrotate.d ssh
debconf.conf lsb-release ssl
debian_version ltrace.conf subgid
default machine-id subgid-
deluser.conf magic subuid
depmod.d magic.mime subuid-
dhcp mailcap sudoers
dictionaries-common mailcap.order sudoers.d
dnsmasq.d manpath.config sysctl.conf
doc-base mime.types sysctl.d
dpkg mke2fs.conf systemd
drirc modprobe.d terminfo
emacs modules thermald
environment modules-load.d thunderbird
firefox mtab timezone
fonts mtools.conf timidity
fstab nanorc tmpfiles.d
fuse.conf network ucf.conf
fwupd.conf NetworkManager udev
gai.conf networks udisks2
gconf newt ufw
gdb nsswitch.conf updatedb.conf
ghostscript openal update-manager
gnome opt update-motd.d
gnome-app-install os-release update-notifier
gnome-vfs-2.0 pam.conf UPower
groff pam.d upstart-xsessions
group papersize usb_modeswitch.conf
group- passwd usb_modeswitch.d
grub.d passwd- vdpau_wrapper.cfg
gshadow pcmcia vim
gshadow- perl vtrgb
gss pki wgetrc
gtk-2.0 pm wildmidi
gtk-3.0 pnm2ppa.conf wpa_supplicant
guest-session polkit-1 X11
hdparm.conf popularity-contest.conf xdg
host.conf ppp xml
hostname presage.xml zsh_command_not_found
8、查看fstab文件
这个文件定义了各硬盘分区挂载到的目录路径。
方法:cat fstab
显示:# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda8 during installation
UUID=bb6033ba-9396-445d-8e0c-9c3a3b7561f7 / ext4 errors=remount-ro 0 1
# /home was on /dev/sda11 during installation
UUID=f9d552e4-9377-4116-8949-dd2031bb37f1 /home ext4 defaults 0 2
# /my_space was on /dev/sda14 during installation
UUID=a0622d19-a5c7-4538-821e-43a3485a0bb7 /my_space ext4 defaults 0 2
# /tmp was on /dev/sda12 during installation
UUID=4d744293-38dc-4534-a959-e620e4161852 /tmp ext4 defaults 0 2
# /usr was on /dev/sda9 during installation
UUID=2b9c8b40-5ecc-4061-8aad-32fe551f24cc /usr ext4 defaults 0 2
# /var was on /dev/sda10 during installation
UUID=0a6e208f-db99-4320-a9c6-22328e2d1c56 /var ext4 defaults 0 2
# swap was on /dev/sda13 during installation
UUID=a030a3c7-5ff1-4ad7-a7c8-c0bd81b8d954 none swap sw 0 0
9、查看以b开头的文件
方法:cat b<TAB><TAB>
显示:cat: 'b<TAB><TAB>': No such file or directory
方法:ca<TAB><TAB>
显示:cat: 'b<TAB><TAB>': No such file or directory
10、查看以p或c结尾的文件
方法:ls *[pc]
显示:bash.bashrc group lintianrc mailcap printcap wgetrc
drirc inputrc magic nanorc rpc


console-setup:
cached.kmap.gz compose.ISO-8859-13.inc compose.ISO-8859-8.inc
compose.ARMSCII-8.inc compose.ISO-8859-14.inc compose.ISO-8859-9.inc
compose.CP1251.inc compose.ISO-8859-15.inc compose.KOI8-R.inc
compose.CP1255.inc compose.ISO-8859-16.inc compose.KOI8-U.inc
compose.CP1256.inc compose.ISO-8859-1.inc compose.TIS-620.inc
compose.GEORGIAN-ACADEMY.inc compose.ISO-8859-2.inc compose.VISCII.inc
compose.GEORGIAN-PS.inc compose.ISO-8859-3.inc ISO-8859-1.acm
compose.IBM1133.inc compose.ISO-8859-4.inc remap.inc
compose.ISIRI-3342.inc compose.ISO-8859-5.inc Uni2-Fixed16.psf.gz
compose.ISO-8859-10.inc compose.ISO-8859-6.inc vtrgb
compose.ISO-8859-11.inc compose.ISO-8859-7.inc vtrgb.vga


dhcp:
debug dhclient.conf dhclient-enter-hooks.d dhclient-exit-hooks.d


hp:
hplip.conf


ldap:
ldap.conf


ppp:
chap-secrets ip-up ipv6-down.d options peers
ip-down ip-up.d ipv6-up options.pptp resolv
ip-down.d ipv6-down ipv6-up.d pap-secrets
11、查看以5-7结尾的文件
方法:ls *[5-7]
显示:ImageMagick-6:
coder.xml magic.xml thresholds.xml type.xml
colors.xml mime.xml type-dejavu.xml
delegates.xml policy.xml type-ghostscript.xml
log.xml quantization-table.xml type-windows.xml


python2.7:
sitecustomize.py


python3.5:
sitecustomize.py
查看以v-w结尾的文件
方法:ls *[v-w]
显示:gshadow hosts.allow shadow


insserv:
overrides


udev:
hwdb.d rules.d udev.conf


ufw:
after6.rules applications.d before.rules user6.rules
after.init before6.rules sysctl.conf user.rules
after.rules before.init ufw.conf
12、显示当前目录
方法:pwd
显示:/etc
13、改变目录
方法:cd
显示:wyx@wys-pc:~$
14、列目录
目录后面加/,可执行文件后面加*,链接文件后面加@
方法:ls -F
显示:Desktop/ Downloads/ hello.c Pictures/ Templates/ Videos/
Documents/ examples.desktop Music/ Public/ test*
列出包含隐藏文件在内的所有文件,并以参数-F形式显示
方法:ls -aF
显示:./ examples.desktop Public/
../ .gconf/ .sogouinput/
.bash_history .gnome/ .ssh/
.bash_logout .gnupg/ .sudo_as_admin_successful
.bashrc hello.c .swp
.byteexec/ .ICEauthority Templates/
.cache/ .*/ test*
.compiz/ .local/ Videos/
.config/ .mozilla/ .viminfo
.dbus/ Music/ .Xauthority
Desktop/ Pictures/ .xinputrc
.dmrc .pki/ .xsession-errors
Documents/ .presage/ .xsession-errors.old
Downloads/ .profile
查看文件的各种属性,依次显示:文件权限标志、文件链接个数、文件所有者的用户名、该用户所在的用户组组名、文件大小、最后依次被修改的日期、时间、文件名
方法:ls -l
显示:total 60
drwxr-xr-x 2 wyx wyx 4096 9月 22 14:48 Desktop
drwxr-xr-x 2 wyx wyx 4096 9月 16 09:43 Documents
drwxr-xr-x 3 wyx wyx 4096 10月 15 22:11 Downloads
-rw-r--r-- 1 wyx wyx 8980 9月 16 08:44 examples.desktop
-rw-rw-r-- 1 wyx wyx 67 9月 18 20:56 hello.c
drwxr-xr-x 3 wyx wyx 4096 9月 22 15:32 Music
drwxr-xr-x 2 wyx wyx 4096 9月 25 19:50 Pictures
drwxr-xr-x 2 wyx wyx 4096 9月 16 09:43 Public
drwxr-xr-x 2 wyx wyx 4096 9月 16 09:43 Templates
-rwxrwxr-x 1 wyx wyx 8608 9月 18 20:56 test
drwxr-xr-x 2 wyx wyx 4096 9月 16 09:43 Videos
查看特定目录下的文件
方法:ls 目录名(Downloads)
显示:bdtrans_1.2.5_chrome.crx
sublime_text_3
学号-姓名-2017年秋季卓越班《操作系统》实验1.docx
【批量下载】学号-姓名-2017年秋季卓越班《操作系统》实验1等.zip