[root@centos7-1 ~]# ps -fe | grep nginx
root 9754 8934 0 22:05 pts/0 00:00:00 grep --color=auto nginx
root 30638 1 0 11月30 ? 00:00:00 nginx: master process ./nginx
nobody 30639 30638 0 11月30 ? 00:00:00 nginx: worker process
[root@centos7-1 ~]# cd proc/9754/fd
-bash: cd: proc/9754/fd: 没有那个文件或目录
[root@centos7-1 ~]# cd proc/30639/fd
-bash: cd: proc/30639/fd: 没有那个文件或目录
[root@centos7-1 ~]# cd /proc/30639/fd
[root@centos7-1 fd]# ll
总用量 0
lrwx------ 1 nobody nobody 64 12月 2 22:07 0 -> /dev/null
lrwx------ 1 nobody nobody 64 12月 2 22:07 1 -> /dev/null
l-wx------ 1 nobody nobody 64 12月 2 22:07 2 -> /opt/vickie/nginx/logs/error.log
l-wx------ 1 nobody nobody 64 12月 2 22:07 4 -> /opt/vickie/nginx/logs/access.log
l-wx------ 1 nobody nobody 64 12月 2 22:07 5 -> /opt/vickie/nginx/logs/error.log
lrwx------ 1 nobody nobody 64 12月 2 22:07 6 -> socket:[211577]
lrwx------ 1 nobody nobody 64 12月 2 22:07 7 -> socket:[211580]
lrwx------ 1 nobody nobody 64 12月 2 22:07 8 -> anon_inode:[eventpoll]
[root@centos7-1 fd]# cd
[root@centos7-1 ~]# cd shell
[root@centos7-1 shell]# ll
总用量 8
-rwxr-xr-x 1 root root 59 11月 29 17:34 file1.txt
-rwxr-xr-x 1 root root 1833 11月 29 17:19 profile
[root@centos7-1 shell]# ls -l /
总用量 28
lrwxrwxrwx. 1 root root 7 9月 27 02:39 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 11月 14 15:58 boot
drwxr-xr-x 20 root root 3320 11月 28 20:24 dev
drwxr-xr-x. 144 root root 8192 12月 2 09:20 etc
drwxr-xr-x. 6 root root 63 11月 27 18:27 home
lrwxrwxrwx. 1 root root 7 9月 27 02:39 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 9月 27 02:39 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 media
drwxr-xr-x. 2 root root 6 4月 11 2018 mnt
drwxr-xr-x. 4 root root 30 11月 28 18:45 opt
dr-xr-xr-x 210 root root 0 11月 27 11:43 proc
dr-xr-x---. 7 root root 4096 12月 2 22:05 root
drwxr-xr-x 41 root root 1240 12月 2 08:19 run
lrwxrwxrwx. 1 root root 8 9月 27 02:39 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 4月 11 2018 srv
dr-xr-xr-x 13 root root 0 11月 27 18:57 sys
drwxrwxrwt. 24 root root 4096 12月 2 09:42 tmp
drwxr-xr-x. 14 root root 167 11月 28 19:35 usr
drwxr-xr-x. 22 root root 4096 11月 28 22:19 var
drwx------ 2 root sharevickie 24 11月 27 19:22 vickieshare
drwxr-xr-x 3 root root 15 11月 16 12:09 vik
[root@centos7-1 shell]# ls -l / 1>ls.txt
[root@centos7-1 shell]# ll
总用量 12
-rwxr-xr-x 1 root root 59 11月 29 17:34 file1.txt
-rw-r--r-- 1 root root 1271 12月 2 22:10 ls.txt
-rwxr-xr-x 1 root root 1833 11月 29 17:19 profile
[root@centos7-1 shell]# cat ls.txt
总用量 28
lrwxrwxrwx. 1 root root 7 9月 27 02:39 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 11月 14 15:58 boot
drwxr-xr-x 20 root root 3320 11月 28 20:24 dev
drwxr-xr-x. 144 root root 8192 12月 2 09:20 etc
drwxr-xr-x. 6 root root 63 11月 27 18:27 home
lrwxrwxrwx. 1 root root 7 9月 27 02:39 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 9月 27 02:39 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 media
drwxr-xr-x. 2 root root 6 4月 11 2018 mnt
drwxr-xr-x. 4 root root 30 11月 28 18:45 opt
dr-xr-xr-x 209 root root 0 11月 27 11:43 proc
dr-xr-x---. 7 root root 4096 12月 2 22:05 root
drwxr-xr-x 41 root root 1240 12月 2 08:19 run
lrwxrwxrwx. 1 root root 8 9月 27 02:39 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 4月 11 2018 srv
dr-xr-xr-x 13 root root 0 11月 27 18:57 sys
drwxrwxrwt. 24 root root 4096 12月 2 09:42 tmp
drwxr-xr-x. 14 root root 167 11月 28 19:35 usr
drwxr-xr-x. 22 root root 4096 11月 28 22:19 var
drwx------ 2 root sharevickie 24 11月 27 19:22 vickieshare
drwxr-xr-x 3 root root 15 11月 16 12:09 vik
[root@centos7-1 shell]# ls -l /etc 1>ls.txt
[root@centos7-1 shell]# vi ls.txt
[root@centos7-1 shell]# ls -l / 1>>ls.txt
[root@centos7-1 shell]# cat ls.txt
总用量 1496
drwxr-xr-x. 3 root root 101 9月 27 02:45 abrt
-rw-r--r--. 1 root root 16 9月 27 03:04 adjtime
-rw-r--r--. 1 root root 1518 6月 7 2013 aliases
-rw-r--r--. 1 root root 12288 9月 27 03:29 aliases.db
drwxr-xr-x. 3 root root 65 9月 27 02:55 alsa
drwxr-xr-x. 2 root root 4096 9月 27 02:57 alternatives
-rw-------. 1 root root 541 4月 11 2018 anacrontab
-rw-r--r--. 1 root root 55 10月 30 2018 asound.conf
-rw-r--r--. 1 root root 1 10月 31 2018 at.deny
drwxr-x---. 3 root root 43 9月 27 02:45 audisp
drwxr-x---. 3 root root 83 9月 27 03:29 audit
-rw-r--r--. 1 root root 14622 10月 31 2018 autofs.conf
-rw-------. 1 root root 232 10月 31 2018 autofs_ldap_auth.conf
-rw-r--r--. 1 root root 795 10月 31 2018 auto.master
drwxr-xr-x. 2 root root 6 10月 31 2018 auto.master.d
-rw-r--r--. 1 root root 524 10月 31 2018 auto.misc
-rwxr-xr-x. 1 root root 1260 10月 31 2018 auto.net
-rwxr-xr-x. 1 root root 687 10月 31 2018 auto.smb
drwxr-xr-x. 4 root root 71 9月 27 02:55 avahi
drwxr-xr-x. 2 root root 4096 9月 27 02:56 bash_completion.d
-rw-r--r--. 1 root root 2853 10月 31 2018 bashrc
drwxr-xr-x. 2 root root 6 10月 31 2018 binfmt.d
drwxr-xr-x. 2 root root 23 9月 27 02:44 bluetooth
drwxr-xr-x. 2 root root 12288 9月 27 02:45 brltty
-rw-r--r--. 1 root root 21929 4月 11 2018 brltty.conf
-rw-r--r--. 1 root root 38 11月 23 2018 centos-release
-rw-r--r--. 1 root root 51 11月 23 2018 centos-release-upstream
drwxr-xr-x. 2 root root 29 9月 27 02:45 certmonger
-rw-r--r--. 1 root root 676 10月 31 2018 cgconfig.conf
drwxr-xr-x. 2 root root 6 10月 31 2018 cgconfig.d
-rw-r--r--. 1 root root 265 9月 27 02:55 cgrules.conf
-rw-r--r--. 1 root root 131 10月 31 2018 cgsnapshot_blacklist.conf
drwxr-xr-x. 2 root root 6 8月 4 2017 chkconfig.d
-rw-r--r--. 1 root root 1108 4月 13 2018 chrony.conf
-rw-r-----. 1 root chrony 481 9月 15 2017 chrony.keys
drwxr-xr-x. 2 root root 26 9月 27 02:55 cifs-utils
drwxr-xr-x. 2 root root 54 9月 27 02:55 cron.d
drwxr-xr-x. 2 root root 57 9月 27 02:55 cron.daily
-rw-------. 1 root root 0 4月 11 2018 cron.deny
drwxr-xr-x. 2 root root 22 6月 10 2014 cron.hourly
drwxr-xr-x. 2 root root 6 6月 10 2014 cron.monthly
-rw-r--r--. 1 root root 451 6月 10 2014 crontab
drwxr-xr-x. 2 root root 6 6月 10 2014 cron.weekly
-rw-------. 1 root root 0 9月 27 02:31 crypttab
-rw-r--r--. 1 root root 1620 10月 31 2018 csh.cshrc
-rw-r--r--. 1 root root 866 10月 31 2018 csh.login
drwxr-xr-x. 5 root lp 4096 11月 29 09:29 cups
drwxr-xr-x. 2 root root 34 9月 27 02:50 cupshelpers
drwxr-xr-x. 4 root root 78 9月 27 02:42 dbus-1
drwxr-xr-x. 4 root root 31 9月 27 02:43 dconf
drwxr-xr-x. 2 root root 44 11月 28 18:21 default
drwxr-xr-x. 2 root root 40 9月 27 02:49 depmod.d
drwxr-x---. 4 root root 53 9月 27 02:44 dhcp
-rw-r--r--. 1 root root 5090 10月 30 2018 DIR_COLORS
-rw-r--r--. 1 root root 5725 10月 30 2018 DIR_COLORS.256color
-rw-r--r--. 1 root root 4669 10月 30 2018 DIR_COLORS.lightbgcolor
-rw-r--r--. 1 root root 1174 4月 11 2018 dleyna-server-service.conf
-rw-r--r--. 1 root root 26832 10月 31 2018 dnsmasq.conf
drwxr-xr-x. 2 root root 6 10月 31 2018 dnsmasq.d
-rw-r--r--. 1 root root 1285 11月 3 2018 dracut.conf
drwxr-xr-x. 2 root root 6 11月 3 2018 dracut.conf.d
-rw-r--r--. 1 root root 12636 11月 1 2018 drirc
-rw-r--r-- 1 root root 112 8月 6 21:44 e2fsck.conf
drwxr-xr-x. 3 root root 37 9月 27 02:43 egl
-rw-r--r--. 1 root root 4760 6月 10 2014 enscript.cfg
-rw-r--r--. 1 root root 0 10月 31 2018 environment
-rw-r--r--. 1 root root 1317 4月 11 2018 ethertypes
-rw-r--r--. 1 root root 0 6月 7 2013 exports
drwxr-xr-x. 2 root root 6 11月 8 2018 exports.d
lrwxrwxrwx. 1 root root 56 9月 27 02:40 favicon.png -> /usr/share/icons/hicolor/16x16/apps/fedora-logo-icon.png
drwxr-xr-x. 2 root root 22 9月 27 02:49 fcoe
drwxr-xr-x. 2 root root 46 9月 27 02:44 festival
-rw-r--r--. 1 root root 70 10月 31 2018 filesystems
drwxr-xr-x. 3 root root 18 9月 27 02:54 firefox
drwxr-x---. 7 root root 133 9月 27 02:44 firewalld
drwxr-xr-x. 3 root root 23 9月 27 02:46 flatpak
drwxr-xr-x. 3 root root 38 9月 27 02:47 fonts
-rw-r--r--. 1 root root 20 10月 31 2018 fprintd.conf
-rw-r--r--. 1 root root 465 9月 27 02:31 fstab
-rw-r--r--. 1 root root 38 10月 30 2018 fuse.conf
drwxr-xr-x. 3 root root 59 9月 27 02:46 fwupd
drwxr-xr-x. 7 root root 107 9月 27 02:43 gconf
drwxr-xr-x. 2 root root 6 8月 2 2017 gcrypt
-rw-r--r--. 1 root root 265 10月 30 2018 gdbinit
drwxr-xr-x. 2 root root 6 10月 30 2018 gdbinit.d
drwxr-xr-x. 6 root root 107 9月 27 02:52 gdm
drwxr-xr-x. 2 root root 26 9月 27 02:46 geoclue
-rw-r--r--. 1 root root 842 10月 31 2018 GeoIP.conf
-rw-r--r--. 1 root root 858 10月 31 2018 GeoIP.conf.default
drwxr-xr-x. 3 root root 18 9月 27 02:48 ghostscript
drwxr-xr-x. 3 root root 26 9月 27 02:43 glvnd
drwxr-xr-x. 2 root root 6 7月 13 2018 gnupg
-rw-r--r--. 1 root root 94 3月 25 2017 GREP_COLORS
drwxr-xr-x. 4 root root 40 9月 27 02:40 groff
-rw-r--r-- 1 root root 1077 11月 28 22:19 group
-rw-r--r--. 1 root root 1064 11月 27 19:04 group-
lrwxrwxrwx. 1 root root 22 9月 27 02:44 grub2.cfg -> ../boot/grub2/grub.cfg
drwx------. 2 root root 182 9月 27 03:02 grub.d
---------- 1 root root 867 11月 28 22:19 gshadow
----------. 1 root root 856 11月 27 19:04 gshadow-
drwxr-xr-x. 3 root root 20 9月 14 02:05 gss
drwxr-xr-x. 2 root root 79 9月 27 02:45 gssproxy
-rw-r--r--. 1 root root 9 6月 7 2013 host.conf
-rw-r--r--. 1 root root 22 9月 27 03:04 hostname
-rw-r--r-- 1 root root 257 10月 5 17:25 hosts
-rw-r--r--. 1 root root 370 6月 7 2013 hosts.allow
-rw-r--r--. 1 root root 460 6月 7 2013 hosts.deny
drwxr-xr-x. 2 root root 24 9月 27 02:46 hp
drwxr-xr-x 5 root root 92 11月 28 22:19 httpd
-rw-r--r--. 1 root root 4849 4月 11 2018 idmapd.conf
lrwxrwxrwx. 1 root root 11 9月 27 02:39 init.d -> rc.d/init.d
-rw-r--r--. 1 root root 511 10月 31 2018 inittab
-rw-r--r--. 1 root root 942 6月 7 2013 inputrc
drwxr-xr-x. 3 root root 19 9月 27 02:39 ipa
drwxr-xr-x. 2 root root 159 9月 27 02:41 iproute2
-rw-r--r--. 1 root root 1073 10月 31 2018 ipsec.conf
drwx------. 3 root root 22 9月 27 02:45 ipsec.d
-rw-------. 1 root root 31 10月 31 2018 ipsec.secrets
drwxr-xr-x. 2 root root 52 9月 27 02:43 iscsi
-rw-r--r--. 1 root root 23 11月 23 2018 issue
-rw-r--r--. 1 root root 22 11月 23 2018 issue.net
drwxr-xr-x. 3 root root 62 9月 27 02:41 java
drwxr-xr-x. 2 root root 6 11月 21 2015 jvm
drwxr-xr-x. 2 root root 6 11月 21 2015 jvm-commmon
-rw-r--r--. 1 root root 7265 9月 27 02:44 kdump.conf
drwxr-xr-x. 3 root root 24 9月 27 02:56 kernel
-rw-r--r-- 1 root root 641 9月 14 00:40 krb5.conf
drwxr-xr-x. 2 root root 6 9月 14 02:05 krb5.conf.d
-rw-r--r--. 1 root root 478 10月 31 2018 ksmtuned.conf
-rw-r--r-- 1 root root 84155 11月 28 22:19 ld.so.cache
-rw-r--r-- 1 root root 28 2月 28 2013 ld.so.conf
drwxr-xr-x. 2 root root 129 8月 7 07:03 ld.so.conf.d
-rw-r-----. 1 root root 191 6月 20 2018 libaudit.conf
drwxr-xr-x. 3 root root 20 9月 27 02:43 libblockdev
drwxr-xr-x. 2 root root 4096 9月 27 02:43 libibverbs.d
drwxr-xr-x. 2 root root 35 9月 27 02:39 libnl
drwxr-xr-x. 6 root root 187 9月 27 02:43 libreport
-rw-r--r--. 1 root root 2391 10月 13 2013 libuser.conf
drwx------. 5 root root 199 9月 27 03:29 libvirt
-rw-r--r--. 1 root root 19 9月 27 03:04 locale.conf
lrwxrwxrwx. 1 root root 35 9月 27 03:04 localtime -> ../usr/share/zoneinfo/Asia/Shanghai
-rw-r--r--. 1 root root 2028 10月 30 2018 login.defs
-rw-r--r--. 1 root root 662 7月 31 2013 logrotate.conf
drwxr-xr-x. 2 root root 243 11月 28 22:19 logrotate.d
drwxr-xr-x. 3 root root 43 9月 27 02:43 lsm
drwxr-xr-x. 6 root root 100 9月 27 02:44 lvm
-r--r--r--. 1 root root 33 9月 27 02:42 machine-id
-rw-r--r--. 1 root root 111 10月 31 2018 magic
-rw-r--r-- 1 root root 272 5月 15 2013 mailcap
-rw-r--r--. 1 root root 1968 4月 11 2018 mail.rc
-rw-r--r--. 1 root root 5122 11月 5 2018 makedumpfile.conf.sample
-rw-r--r--. 1 root root 5171 10月 31 2018 man_db.conf
drwxr-xr-x. 2 root root 6 11月 21 2015 maven
-rw-r--r-- 1 root root 51787 5月 15 2013 mime.types
-rw-r--r-- 1 root root 936 8月 9 07:15 mke2fs.conf
drwxr-xr-x. 2 root root 138 9月 27 02:55 modprobe.d
drwxr-xr-x. 2 root root 6 10月 31 2018 modules-load.d
-rw-r--r--. 1 root root 0 6月 7 2013 motd
lrwxrwxrwx. 1 root root 17 9月 27 02:31 mtab -> /proc/self/mounts
-rw-r--r--. 1 root root 2620 6月 10 2014 mtools.conf
drwxr-xr-x. 2 root root 6 10月 31 2018 multipath
-rw-r--r--. 1 root root 570 8月 16 2018 my.cnf
drwxr-xr-x. 2 root root 31 9月 27 02:41 my.cnf.d
-rw-r--r--. 1 root root 8892 6月 10 2014 nanorc
drwxr-xr-x. 2 root root 26 9月 27 02:44 ndctl
-rw-r--r--. 1 root root 767 10月 31 2018 netconfig
-rwxr-xr-x 1 root root 1833 11月 16 12:14 network
drwxr-xr-x. 8 root root 145 9月 27 02:53 NetworkManager
-rw-r--r--. 1 root root 58 10月 31 2018 networks
-rw-r--r--. 1 root root 967 11月 8 2018 nfs.conf
-rw-r--r--. 1 root root 3391 11月 8 2018 nfsmount.conf
-rw-r--r--. 1 root root 1746 9月 27 02:42 nsswitch.conf
-rw-r--r--. 1 root root 1735 10月 30 2018 nsswitch.conf.bak
-rw-r--r-- 1 root root 1938 8月 7 07:00 nsswitch.conf.rpmnew
drwxr-xr-x. 3 root root 52 9月 27 02:46 ntp
-rw-r--r--. 1 root root 2000 4月 11 2018 ntp.conf
-rw-r--r--. 1 root root 91 12月 3 2012 numad.conf
drwxr-xr-x. 2 root root 6 3月 6 2015 oddjob
-rw-r--r--. 1 root root 4922 3月 6 2015 oddjobd.conf
drwxr-xr-x. 2 root root 70 9月 27 02:45 oddjobd.conf.d
drwxr-xr-x. 3 root root 36 9月 27 02:41 openldap
drwxr-xr-x. 2 root root 6 4月 11 2018 opt
-rw-r--r--. 1 root root 393 11月 23 2018 os-release
drwxr-xr-x. 2 root root 92 9月 27 02:55 PackageKit
drwxr-xr-x. 2 root root 4096 11月 28 18:28 pam.d
-rw-r--r-- 1 root root 2494 11月 28 22:19 passwd
-rw-r--r--. 1 root root 2441 11月 27 18:27 passwd-
-rw-r--r--. 1 root root 1362 6月 10 2014 pbm2ppa.conf
-rw-r--r--. 1 root root 2872 6月 10 2014 pinforc
drwxr-xr-x. 3 root root 21 9月 27 02:39 pkcs11
drwxr-xr-x. 12 root root 151 9月 27 02:55 pki
drwxr-xr-x. 2 root root 28 9月 27 02:47 plymouth
drwxr-xr-x. 5 root root 52 9月 27 02:39 pm
-rw-r--r--. 1 root root 6300 6月 10 2014 pnm2ppa.conf
drwxr-xr-x. 5 root root 72 9月 27 02:42 polkit-1
drwxr-xr-x. 2 root root 6 6月 10 2014 popt.d
drwxr-xr-x. 2 root root 154 9月 27 02:55 postfix
drwxr-xr-x. 3 root root 219 9月 27 02:44 ppp
drwxr-xr-x. 2 root root 105 9月 27 02:45 prelink.conf.d
-rw-r--r--. 1 root root 233 6月 7 2013 printcap
-rwxr-xr-x 1 root root 1833 11月 15 11:07 profile
drwxr-xr-x. 2 root root 4096 9月 27 02:55 profile.d
-rw-r--r--. 1 root root 6545 10月 31 2018 protocols
drwxr-xr-x. 2 root root 79 9月 27 02:45 pulse
drwxr-xr-x. 2 root root 23 9月 27 02:47 purple
drwxr-xr-x. 2 root root 35 9月 27 02:40 python
drwxr-xr-x. 3 root root 50 9月 27 02:55 qemu-ga
drwxr-xr-x. 2 root root 51 9月 27 02:51 qemu-kvm
-rw-r--r--. 1 root root 433 10月 31 2018 radvd.conf
lrwxrwxrwx. 1 root root 10 9月 27 02:39 rc0.d -> rc.d/rc0.d
lrwxrwxrwx. 1 root root 10 9月 27 02:39 rc1.d -> rc.d/rc1.d
lrwxrwxrwx. 1 root root 10 9月 27 02:39 rc2.d -> rc.d/rc2.d
lrwxrwxrwx. 1 root root 10 9月 27 02:39 rc3.d -> rc.d/rc3.d
lrwxrwxrwx. 1 root root 10 9月 27 02:39 rc4.d -> rc.d/rc4.d
lrwxrwxrwx. 1 root root 10 9月 27 02:39 rc5.d -> rc.d/rc5.d
lrwxrwxrwx. 1 root root 10 9月 27 02:39 rc6.d -> rc.d/rc6.d
drwxr-xr-x. 10 root root 127 9月 27 02:42 rc.d
lrwxrwxrwx. 1 root root 13 9月 27 02:42 rc.local -> rc.d/rc.local
drwxr-xr-x. 3 root root 94 9月 27 02:43 rdma
lrwxrwxrwx. 1 root root 14 9月 27 02:39 redhat-release -> centos-release
-rw-r--r--. 1 root root 1787 6月 10 2014 request-key.conf
drwxr-xr-x. 2 root root 77 9月 27 02:55 request-key.d
-rw-r--r-- 1 root root 55 12月 2 09:20 resolv.conf
-rw-r--r--. 1 root root 1 9月 27 02:31 resolv.conf.save
-rw-r--r-- 1 root root 1634 12月 25 2012 rpc
drwxr-xr-x. 2 root root 12
Linux-shell-IO重定向
最新推荐文章于 2022-04-24 13:41:46 发布
本文演示了在Linux环境下使用shell进行IO重定向的一些基本操作,包括使用`ps`命令查找进程,尝试进入进程的`fd`目录查看打开的文件描述符,并通过`ls`命令将输出重定向到文件`ls.txt`。接着,继续追加`/etc`目录的内容到`ls.txt`,最后使用`cat`展示`ls.txt`的内容,展示了如何将命令输出保存到文件中以便后续查看和分析。
摘要由CSDN通过智能技术生成