用netstat -lntp | grep :80

本文介绍如何在XAMPP环境下配置与管理Apache、MySQL和FTP服务,包括启动、停止服务的操作步骤,以及如何通过命令行查找并终止占用特定端口的进程。
用netstat -lntp | grep :80 找出占用80端口的进程例如:[root@localhost ~]# netstat -lntp | grep :80tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      3040/nginx这里的程序名就是nginx尝试用killall [程序名],看能不能关闭他。例如:killall nginx如果不行,用ps 找出他的PID,例如:[root@localhost ~]# ps aux | grep nginx | grep -v greproot      5406  0.0  0.2   5996   756 ?        Ss   03:32   0:00 nginx: master process /usr/local/webserver/nginx/sbin/nginx这里的pid是 5406然后用kill命令关掉它。例如:kill 5406PS:如果是通过apt-get安装的apache,可以尝试通过/etc/init.d/[程序名] stop 停止进程,或者通过chkconfig [程序名] off 关闭开机启动。

lampp/var/perl/
lampp/var/perl/cpan/
lampp/var/perl/cpanplus/
lampp/var/proftpd.delay
lampp/RELEASENOTES
lampp/php/
lampp/php/man/
lampp/php/man/man1/
lampp/php/man/man1/php.1
lampp/php/man/man1/phpize.1
lampp/php/man/man1/php-config.1
[root@localhost opt]# ls
lampp  xampp-linux-1.8.1.tar.gz
[root@localhost opt]# cd lampp
[root@localhost lampp]# ls
bin  cgi-bin  error  etc  htdocs  icons  lampp  lib  libexec  licenses  logs  modules  php  phpmyadmin  RELEASENOTES  sbin  share  tmp  var
[root@localhost lampp]# ./lampp start
XAMPP: SELinux is activated. Making XAMPP fit SELinux...
Starting XAMPP for Linux 1.8.1...
XAMPP: Another web server daemon is already running.
XAMPP: Another MySQL daemon is already running.
XAMPP: Another FTP daemon is already running.
XAMPP for Linux started.
[root@localhost lampp]# XAMPP: Another web server daemon is already running.
-bash: XAMPP:: command not found
[root@localhost lampp]# apache2 stop
-bash: apache2: command not found
[root@localhost lampp]# find / -name  apache
/usr/share/javadoc/xmlrpc-2.0.1/org/apache
/opt/lampp/licenses/apache
[root@localhost lampp]# sudo /etc/init.d/apache2 stop
sudo: /etc/init.d/apache2: command not found
[root@localhost lampp]# cd /etc/init.d
[root@localhost init.d]# ls
acpid           bluetooth           dund       httpd       kdump         mdmonitor      network         pand             restorecond     smartd          xfs
anacron         capi                firstboot  ibmasm      killall       mdmpd          NetworkManager  pcscd            rpcgssd         sshd            ypbind
apmd            conman              functions  ip6tables   krb524        messagebus     nfs             portmap          rpcidmapd       syslog          yum-updatesd
atd             cpuspeed            gpm        ipmi        kudzu         microcode_ctl  nfslock         psacct           rpcsvcgssd      tcsd
auditd          crond               haldaemon  iptables    lisa          multipathd     nscd            rawdevices       saslauthd       vncserver
autofs          cups                halt       irda        lm_sensors    netconsole     ntpd            rdisc            sendmail        wdaemon
avahi-daemon    cups-config-daemon  hidd       irqbalance  lvm2-monitor  netfs          oddjobd         readahead_early  setroubleshoot  winbind
avahi-dnsconfd  dnsmasq             hsqldb     isdn        mcstrans      netplugd       openibd         readahead_later  single          wpa_supplicant
[root@localhost init.d]# ./lampp
-bash: ./lampp: No such file or directory
[root@localhost init.d]# lampp
-bash: lampp: command not found
[root@localhost init.d]# pwd
/etc/init.d
[root@localhost init.d]# ls
acpid           bluetooth           dund       httpd       kdump         mdmonitor      network         pand             restorecond     smartd          xfs
anacron         capi                firstboot  ibmasm      killall       mdmpd          NetworkManager  pcscd            rpcgssd         sshd            ypbind
apmd            conman              functions  ip6tables   krb524        messagebus     nfs             portmap          rpcidmapd       syslog          yum-updatesd
atd             cpuspeed            gpm        ipmi        kudzu         microcode_ctl  nfslock         psacct           rpcsvcgssd      tcsd
auditd          crond               haldaemon  iptables    lisa          multipathd     nscd            rawdevices       saslauthd       vncserver
autofs          cups                halt       irda        lm_sensors    netconsole     ntpd            rdisc            sendmail        wdaemon
avahi-daemon    cups-config-daemon  hidd       irqbalance  lvm2-monitor  netfs          oddjobd         readahead_early  setroubleshoot  winbind
avahi-dnsconfd  dnsmasq             hsqldb     isdn        mcstrans      netplugd       openibd         readahead_later  single          wpa_supplicant
[root@localhost init.d]# cd  /opt
[root@localhost opt]# ls
lampp  xampp-linux-1.8.1.tar.gz
[root@localhost opt]# cd  lampp
[root@localhost lampp]# ls
bin  cgi-bin  error  etc  htdocs  icons  lampp  lib  libexec  licenses  logs  modules  php  phpmyadmin  RELEASENOTES  sbin  share  tmp  var
[root@localhost lampp]# lampp
-bash: lampp: command not found
[root@localhost lampp]# ./lampp
Usage: ./lampp <action>

        start        Start XAMPP (Apache, MySQL and eventually others)
        startapache  Start only Apache
        startssl     Start only SSL support
        startmysql   Start only MySQL
        startftp     Start only ProFTPD

        stop         Stop XAMPP (Apache, MySQL and eventually others)
        stopapache   Stop only Apache
        stopssl      Stop only SSL support
        stopmysql    Stop only MySQL
        stopftp      Stop only ProFTPD

        reload       Reload XAMPP (Apache, MySQL and eventually others)
        reloadapache Reload only Apache
        reloadmysql  Reload only MySQL
        reloadftp    Reload only ProFTPD

        restart      Stop and start XAMPP
        security     Check XAMPP's security

        php5         Activate PHP5
        phpstatus    Which version of PHP is active?

        backup       Make backup file of your XAMPP config, log and data files
        panel        Starts graphical XAMPP control panel

[root@localhost lampp]# ./lampp  panel
Traceback (most recent call last):
  File "xampp-control-panel.py", line 18, in ?
    import gtk
  File "/usr/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line 48, in ?
    from gtk import _gtk
ImportError: /usr/lib/libcairo.so.2: undefined symbol: FT_GlyphSlot_Embolden
[root@localhost lampp]# ./lampp  stop
Stopping XAMPP for Linux 1.8.1...
XAMPP: XAMPP-Apache is not running.
XAMPP: XAMPP-MySQL is not running.
XAMPP: XAMPP-ProFTPD is not running.
XAMPP stopped.
[root@localhost lampp]# ./lampp start
Starting XAMPP for Linux 1.8.1...
XAMPP: Another web server daemon is already running.
XAMPP: Another MySQL daemon is already running.
XAMPP: Another FTP daemon is already running.
XAMPP for Linux started.
[root@localhost lampp]# rpm -i  apache
error: open of apache failed: No such file or directory
[root@localhost lampp]# rpm -i  apache2
error: open of apache2 failed: No such file or directory
[root@localhost lampp]# rpm -qa  mysql
[root@localhost lampp]# cd  /usr
[root@localhost usr]# cd 
[root@localhost ~]# ls
anaconda-ks.cfg  Desktop  install.log  install.log.syslog
[root@localhost ~]# cd  /usr/local
[root@localhost local]# ls
bin  etc  games  include  lib  libexec  sbin  share  src  srv
[root@localhost local]# rm srv
rm: cannot remove directory `srv': Is a directory
[root@localhost local]# rm -rf  srv
[root@localhost local]# ls
bin  etc  games  include  lib  libexec  sbin  share  src
[root@localhost local]# grep  -n  mysql
netstat -ano |find "8080"

[root@localhost local]# netstat -ano |find "80"
find: 80: No such file or directory
[root@localhost local]# netstat -ano | grep "80"
tcp        0      0 :::80                       :::*                        LISTEN      off (0.00/0/0)
unix  2      [ ACC ]     STREAM     LISTENING     8014   /var/run/audispd_events
unix  19     [ ]         DGRAM                    8082   /dev/log
unix  2      [ ]         DGRAM                    8090  
unix  3      [ ]         STREAM     CONNECTED     8005  
unix  3      [ ]         STREAM     CONNECTED     8004  
[root@localhost local]# rpm -qa | grep MySQL
[root@localhost local]# ./lampp restart
-bash: ./lampp: No such file or directory
[root@localhost local]# cd
[root@localhost ~]# cd  ..
[root@localhost /]# ls
bin  boot  dev  etc  home  lib  lost+found  media  misc  mnt  net  opt  proc  root  sbin  selinux  srv  sys  tmp  usr  var  zh
[root@localhost /]# cd  /opt
[root@localhost opt]# ls
lampp  xampp-linux-1.8.1.tar.gz
[root@localhost opt]# cd  lamp
-bash: cd: lamp: No such file or directory
[root@localhost opt]# cd  lampp
[root@localhost lampp]# ls
bin  cgi-bin  error  etc  htdocs  icons  lampp  lib  libexec  licenses  logs  modules  php  phpmyadmin  RELEASENOTES  sbin  share  tmp  var
[root@localhost lampp]# ./lampp restrat
Usage: ./lampp <action>

        start        Start XAMPP (Apache, MySQL and eventually others)
        startapache  Start only Apache
        startssl     Start only SSL support
        startmysql   Start only MySQL
        startftp     Start only ProFTPD

        stop         Stop XAMPP (Apache, MySQL and eventually others)
        stopapache   Stop only Apache
        stopssl      Stop only SSL support
        stopmysql    Stop only MySQL
        stopftp      Stop only ProFTPD

        reload       Reload XAMPP (Apache, MySQL and eventually others)
        reloadapache Reload only Apache
        reloadmysql  Reload only MySQL
        reloadftp    Reload only ProFTPD

        restart      Stop and start XAMPP
        security     Check XAMPP's security

        php5         Activate PHP5
        phpstatus    Which version of PHP is active?

        backup       Make backup file of your XAMPP config, log and data files
        panel        Starts graphical XAMPP control panel

[root@localhost lampp]# ./lampp restart
Stopping XAMPP for Linux 1.8.1...
XAMPP: XAMPP-Apache is not running.
XAMPP: XAMPP-MySQL is not running.
XAMPP: XAMPP-ProFTPD is not running.
XAMPP stopped.
Starting XAMPP for Linux 1.8.1...
XAMPP: Another web server daemon is already running.
XAMPP: Another MySQL daemon is already running.
XAMPP: Another FTP daemon is already running.
XAMPP for Linux started.
[root@localhost lampp]# ps  -au
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      3250  0.0  0.0   1664   420 tty1     Ss+  22:30   0:00 /sbin/mingetty tty1
root      3251  0.0  0.0   1664   428 tty2     Ss+  22:30   0:00 /sbin/mingetty tty2
root      3252  0.0  0.0   1664   420 tty3     Ss+  22:30   0:00 /sbin/mingetty tty3
root      3253  0.0  0.0   1664   424 tty4     Ss+  22:30   0:00 /sbin/mingetty tty4
root      3254  0.0  0.0   1664   424 tty5     Ss+  22:30   0:00 /sbin/mingetty tty5
root      3255  0.0  0.0   1664   424 tty6     Ss+  22:30   0:00 /sbin/mingetty tty6
root      3364  0.0  0.0  11184  5120 tty7     Ss+  22:30   0:00 /usr/bin/Xorg :0 -br -audit 0 -auth /var/gdm/:0.Xauth -nolisten tcp vt7
root      5045  0.0  0.0   4540  1416 pts/1    Ss   23:00   0:00 -bash
root      5629  0.0  0.0   4260   948 pts/1    R+   23:32   0:00 ps -au
[root@localhost lampp]# ps  -aux
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   2072   624 ?        Ss   22:28   0:01 init [5]                                             
root         2  0.0  0.0      0     0 ?        S<   22:28   0:00 [migration/0]
root         3  0.0  0.0      0     0 ?        SN   22:28   0:00 [ksoftirqd/0]
root         4  0.0  0.0      0     0 ?        S<   22:28   0:00 [watchdog/0]
root         5  0.0  0.0      0     0 ?        S<   22:28   0:00 [migration/1]
root         6  0.0  0.0      0     0 ?        SN   22:28   0:00 [ksoftirqd/1]
root         7  0.0  0.0      0     0 ?        S<   22:28   0:00 [watchdog/1]
root         8  0.0  0.0      0     0 ?        S<   22:28   0:00 [migration/2]
root         9  0.0  0.0      0     0 ?        SN   22:28   0:00 [ksoftirqd/2]
root        10  0.0  0.0      0     0 ?        S<   22:28   0:00 [watchdog/2]
root        11  0.0  0.0      0     0 ?        S<   22:28   0:00 [migration/3]
root        12  0.0  0.0      0     0 ?        SN   22:28   0:00 [ksoftirqd/3]
root        13  0.0  0.0      0     0 ?        S<   22:28   0:00 [watchdog/3]
root        14  0.0  0.0      0     0 ?        S<   22:28   0:00 [migration/4]
root        15  0.0  0.0      0     0 ?        SN   22:28   0:00 [ksoftirqd/4]
root        16  0.0  0.0      0     0 ?        S<   22:28   0:00 [watchdog/4]
root        17  0.0  0.0      0     0 ?        S<   22:28   0:00 [migration/5]
root        18  0.0  0.0      0     0 ?        SN   22:28   0:00 [ksoftirqd/5]
root        19  0.0  0.0      0     0 ?        S<   22:28   0:00 [watchdog/5]
root        20  0.0  0.0      0     0 ?        S<   22:28   0:00 [migration/6]
root        21  0.0  0.0      0     0 ?        SN   22:28   0:00 [ksoftirqd/6]
root        22  0.0  0.0      0     0 ?        S<   22:28   0:00 [watchdog/6]
root        23  0.0  0.0      0     0 ?        S<   22:28   0:00 [migration/7]
root        24  0.0  0.0      0     0 ?        SN   22:28   0:00 [ksoftirqd/7]
root        25  0.0  0.0      0     0 ?        S<   22:28   0:00 [watchdog/7]
root        26  0.0  0.0      0     0 ?        S<   22:28   0:00 [events/0]
root        27  0.0  0.0      0     0 ?        S<   22:28   0:00 [events/1]
root        28  0.0  0.0      0     0 ?        S<   22:28   0:00 [events/2]
root        29  0.0  0.0      0     0 ?        S<   22:28   0:00 [events/3]
root        30  0.0  0.0      0     0 ?        S<   22:28   0:00 [events/4]
root        31  0.0  0.0      0     0 ?        S<   22:28   0:00 [events/5]
root        32  0.0  0.0      0     0 ?        S<   22:28   0:00 [events/6]
root        33  0.0  0.0      0     0 ?        S<   22:28   0:00 [events/7]
root        34  0.0  0.0      0     0 ?        S<   22:28   0:00 [khelper]
root        35  0.0  0.0      0     0 ?        S<   22:28   0:00 [kthread]
root        45  0.0  0.0      0     0 ?        S<   22:28   0:00 [kblockd/0]
root        46  0.0  0.0      0     0 ?        S<   22:28   0:00 [kblockd/1]
root        47  0.0  0.0      0     0 ?        S<   22:28   0:00 [kblockd/2]
root        48  0.0  0.0      0     0 ?        S<   22:28   0:00 [kblockd/3]
root        49  0.0  0.0      0     0 ?        S<   22:28   0:00 [kblockd/4]
root        50  0.0  0.0      0     0 ?        S<   22:28   0:00 [kblockd/5]
root        51  0.0  0.0      0     0 ?        S<   22:28   0:00 [kblockd/6]
root        52  0.0  0.0      0     0 ?        S<   22:28   0:00 [kblockd/7]
root        53  0.0  0.0      0     0 ?        S<   22:28   0:00 [kacpid]
root       163  0.0  0.0      0     0 ?        S<   22:28   0:00 [cqueue/0]
root       164  0.0  0.0      0     0 ?        S<   22:28   0:00 [cqueue/1]
root       165  0.0  0.0      0     0 ?        S<   22:28   0:00 [cqueue/2]
root       166  0.0  0.0      0     0 ?        S<   22:28   0:00 [cqueue/3]
root       167  0.0  0.0      0     0 ?        S<   22:28   0:00 [cqueue/4]
root       168  0.0  0.0      0     0 ?        S<   22:28   0:00 [cqueue/5]
root       169  0.0  0.0      0     0 ?        S<   22:28   0:00 [cqueue/6]
root       170  0.0  0.0      0     0 ?        S<   22:28   0:00 [cqueue/7]
root       173  0.0  0.0      0     0 ?        S<   22:28   0:00 [khubd]
root       175  0.0  0.0      0     0 ?        S<   22:28   0:00 [kseriod]
root       267  0.0  0.0      0     0 ?        S    22:28   0:00 [khungtaskd]
root       268  0.0  0.0      0     0 ?        S    22:28   0:00 [pdflush]
root       269  0.0  0.0      0     0 ?        S    22:28   0:00 [pdflush]
root       270  0.0  0.0      0     0 ?        S<   22:28   0:00 [kswapd0]
root       271  0.0  0.0      0     0 ?        S<   22:28   0:00 [aio/0]
root       272  0.0  0.0      0     0 ?        S<   22:28   0:00 [aio/1]
root       273  0.0  0.0      0     0 ?        S<   22:28   0:00 [aio/2]
root       274  0.0  0.0      0     0 ?        S<   22:28   0:00 [aio/3]
root       275  0.0  0.0      0     0 ?        S<   22:28   0:00 [aio/4]
root       276  0.0  0.0      0     0 ?        S<   22:28   0:00 [aio/5]
root       277  0.0  0.0      0     0 ?        S<   22:28   0:00 [aio/6]
root       278  0.0  0.0      0     0 ?        S<   22:28   0:00 [aio/7]
root       453  0.0  0.0      0     0 ?        S<   22:28   0:00 [kpsmoused]
root       559  0.0  0.0      0     0 ?        S<   22:28   0:00 [mpt_poll_0]
root       560  0.0  0.0      0     0 ?        S<   22:28   0:00 [mpt/0]
root       561  0.0  0.0      0     0 ?        S<   22:29   0:00 [scsi_eh_0]
root       571  0.0  0.0      0     0 ?        S<   22:29   0:00 [ata/0]
root       572  0.0  0.0      0     0 ?        S<   22:29   0:00 [ata/1]
root       573  0.0  0.0      0     0 ?        S<   22:29   0:00 [ata/2]
root       574  0.0  0.0      0     0 ?        S<   22:29   0:00 [ata/3]
root       575  0.0  0.0      0     0 ?        S<   22:29   0:00 [ata/4]
root       576  0.0  0.0      0     0 ?        S<   22:29   0:00 [ata/5]
root       577  0.0  0.0      0     0 ?        S<   22:29   0:00 [ata/6]
root       578  0.0  0.0      0     0 ?        S<   22:29   0:00 [ata/7]
root       579  0.0  0.0      0     0 ?        S<   22:29   0:00 [ata_aux]
root       598  0.0  0.0      0     0 ?        S<   22:29   0:00 [kstriped]
root       635  0.0  0.0      0     0 ?        S<   22:29   0:00 [ksnapd]
root       674  0.0  0.0      0     0 ?        S<   22:29   0:00 [kjournald]
root       705  0.0  0.0      0     0 ?        S<   22:29   0:00 [kauditd]
root       738  0.0  0.0   3096  1632 ?        S<s  22:29   0:00 /sbin/udevd -d
root      1361  0.0  0.0      0     0 ?        S<   22:29   0:00 [kedac]
root      2171  0.0  0.0      0     0 ?        S<   22:29   0:00 [kmpathd/0]
root      2172  0.0  0.0      0     0 ?        S<   22:29   0:00 [kmpathd/1]
root      2174  0.0  0.0      0     0 ?        S<   22:29   0:00 [kmpathd/2]
root      2175  0.0  0.0      0     0 ?        S<   22:29   0:00 [kmpathd/3]
root      2176  0.0  0.0      0     0 ?        S<   22:29   0:00 [kmpathd/4]
root      2177  0.0  0.0      0     0 ?        S<   22:29   0:00 [kmpathd/5]
root      2178  0.0  0.0      0     0 ?        S<   22:29   0:00 [kmpathd/6]
root      2179  0.0  0.0      0     0 ?        S<   22:29   0:00 [kmpathd/7]
root      2180  0.0  0.0      0     0 ?        S<   22:29   0:00 [kmpath_handlerd]
root      2266  0.0  0.0      0     0 ?        S<   22:29   0:00 [kjournald]
root      2442  0.0  0.0   2172   512 ?        Ss   22:30   0:00 mcstransd
root      2625  0.0  0.0  12520   756 ?        S<sl 22:30   0:00 auditd
root      2627  0.0  0.0  12076   676 ?        S<sl 22:30   0:00 /sbin/audispd
root      2644  0.0  0.0  11984 10536 ?        Ss   22:30   0:00 /usr/sbin/restorecond
root      2653  0.0  0.0   1728   568 ?        Ss   22:30   0:00 syslogd -m 0
root      2656  0.0  0.0   1680   400 ?        Ss   22:30   0:00 klogd -x
root      2726  0.0  0.0   2472   368 ?        Ss   22:30   0:00 irqbalance
rpc       2737  0.0  0.0   1816   548 ?        Ss   22:30   0:00 portmap
root      2769  0.0  0.0      0     0 ?        S<   22:30   0:00 [rpciod/0]
root      2770  0.0  0.0      0     0 ?        S<   22:30   0:00 [rpciod/1]
root      2771  0.0  0.0      0     0 ?        S<   22:30   0:00 [rpciod/2]
root      2772  0.0  0.0      0     0 ?        S<   22:30   0:00 [rpciod/3]
root      2773  0.0  0.0      0     0 ?        S<   22:30   0:00 [rpciod/4]
root      2774  0.0  0.0      0     0 ?        S<   22:30   0:00 [rpciod/5]
root      2776  0.0  0.0      0     0 ?        S<   22:30   0:00 [rpciod/6]
root      2777  0.0  0.0      0     0 ?        S<   22:30   0:00 [rpciod/7]
root      2790  0.0  0.0   1868   752 ?        Ss   22:30   0:00 rpc.statd
root      2814  0.0  0.0   5820   644 ?        Ss   22:30   0:00 rpc.idmapd
dbus      2829  0.0  0.0  12992  1076 ?        Ssl  22:30   0:00 dbus-daemon --system
root      2841  0.0  0.0  45476 13320 ?        Ssl  22:30   0:00 /usr/bin/python -E /usr/sbin/setroubleshootd
root      2850  0.0  0.0   2172   760 ?        Ss   22:30   0:00 /usr/sbin/hcid
root      2854  0.0  0.0   1748   508 ?        Ss   22:30   0:00 /usr/sbin/sdpd
root      2895  0.0  0.0      0     0 ?        S<   22:30   0:00 [krfcommd]
root      2933  0.0  0.0  23112  1416 ?        Ssl  22:30   0:00 pcscd
root      2943  0.0  0.0   1676   532 ?        Ss   22:30   0:00 /usr/sbin/acpid
68        2956  0.0  0.0   6232  4204 ?        Ss   22:30   0:01 hald
root      2957  0.0  0.0   3164   988 ?        S    22:30   0:00 hald-runner
68        2965  0.0  0.0   2020   812 ?        S    22:30   0:00 hald-addon-acpi: listening on acpid socket /var/run/acpid.socket
root      2973  0.0  0.0   1976   668 ?        S    22:30   0:00 hald-addon-storage: polling /dev/hda
root      2997  0.0  0.0   1916   460 ?        Ss   22:30   0:00 /usr/bin/hidd --server
root      3031  0.0  0.0  27256  1364 ?        Ssl  22:30   0:00 automount
root      3051  0.0  0.0   7068  1064 ?        Ss   22:30   0:00 /usr/sbin/sshd
root      3060  0.0  0.0  10120  2312 ?        Ss   22:30   0:00 cupsd
root      3082  0.0  0.0   9304  1712 ?        Ss   22:30   0:00 sendmail: accepting connections
smmsp     3091  0.0  0.0   8148  1516 ?        Ss   22:30   0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root      3101  0.0  0.0   1908   364 ?        Ss   22:30   0:00 gpm -m /dev/input/mice -t exps2
root      3110  0.0  0.0   5288  1188 ?        Ss   22:30   0:00 crond
xfs       3139  0.0  0.0   3864  1600 ?        Ss   22:30   0:00 xfs -droppriv -daemon
root      3156  0.0  0.0   2268   440 ?        Ss   22:30   0:00 /usr/sbin/atd
avahi     3183  0.0  0.0   2600  1260 ?        Ss   22:30   0:00 avahi-daemon: running [localhost.local]
avahi     3184  0.0  0.0   2600   316 ?        Ss   22:30   0:00 avahi-daemon: chroot helper
root      3245  0.0  0.0   3516   432 ?        S    22:30   0:00 /usr/sbin/smartd -q never
root      3250  0.0  0.0   1664   420 tty1     Ss+  22:30   0:00 /sbin/mingetty tty1
root      3251  0.0  0.0   1664   428 tty2     Ss+  22:30   0:00 /sbin/mingetty tty2
root      3252  0.0  0.0   1664   420 tty3     Ss+  22:30   0:00 /sbin/mingetty tty3
root      3253  0.0  0.0   1664   424 tty4     Ss+  22:30   0:00 /sbin/mingetty tty4
root      3254  0.0  0.0   1664   424 tty5     Ss+  22:30   0:00 /sbin/mingetty tty5
root      3255  0.0  0.0   1664   424 tty6     Ss+  22:30   0:00 /sbin/mingetty tty6
root      3256  0.0  0.0  15556  2864 ?        Ss   22:30   0:00 /usr/sbin/gdm-binary -nodaemon
root      3319  0.0  0.0  25568 10272 ?        SN   22:30   0:00 /usr/bin/python -tt /usr/sbin/yum-updatesd
root      3353  0.0  0.0   2564  1128 ?        SN   22:30   0:00 /usr/libexec/gam_server
root      3361  0.0  0.0  16168  2324 ?        S    22:30   0:00 /usr/sbin/gdm-binary -nodaemon
root      3363  0.0  0.0  27496  4224 ?        Sl   22:30   0:00 /usr/libexec/gdm-rh-security-token-helper
root      3364  0.0  0.0  11184  5120 tty7     Ss+  22:30   0:00 /usr/bin/Xorg :0 -br -audit 0 -auth /var/gdm/:0.Xauth -nolisten tcp vt7
gdm       3387  0.0  0.1  33540 17628 ?        Ss   22:30   0:00 /usr/libexec/gdmgreeter
root      4570  0.0  0.1  52176 16652 ?        Ss   22:34   0:00 /opt/lampp/bin/httpd -k start -DPHP5 -E /opt/lampp/logs/error_log
root      4588  0.0  0.0   4492  1152 ?        S    22:34   0:00 /bin/sh /opt/lampp/bin/mysqld_safe --datadir=/opt/lampp/var/mysql --pid-file=/opt/lampp/var/mysql/localhost.localdo
nobody    4948  0.0  0.1 216708 25736 ?        Sl   22:34   0:00 /opt/lampp/sbin/mysqld --basedir=/opt/lampp --datadir=/opt/lampp/var/mysql --plugin-dir=/opt/lampp/lib/mysql/plugin
nobody    4965  0.0  0.0  47684 12060 ?        S    22:34   0:00 /opt/lampp/bin/httpd -k start -DPHP5 -E /opt/lampp/logs/error_log
nobody    4966  0.0  0.0  52444 14540 ?        S    22:34   0:00 /opt/lampp/bin/httpd -k start -DPHP5 -E /opt/lampp/logs/error_log
nobody    4967  0.0  0.0  52308 14396 ?        S    22:34   0:00 /opt/lampp/bin/httpd -k start -DPHP5 -E /opt/lampp/logs/error_log
nobody    4968  0.0  0.0  52444 14548 ?        S    22:34   0:00 /opt/lampp/bin/httpd -k start -DPHP5 -E /opt/lampp/logs/error_log
nobody    4969  0.0  0.0  52308 14484 ?        S    22:34   0:00 /opt/lampp/bin/httpd -k start -DPHP5 -E /opt/lampp/logs/error_log
nobody    4970  0.0  0.0  52308 14484 ?        S    22:34   0:00 /opt/lampp/bin/httpd -k start -DPHP5 -E /opt/lampp/logs/error_log
nobody    4989  0.0  0.0   8004  1528 ?        Ss   22:35   0:00 proftpd: (accepting connections)
nobody    5039  0.0  0.0  52176 13616 ?        S    22:58   0:00 /opt/lampp/bin/httpd -k start -DPHP5 -E /opt/lampp/logs/error_log
root      5042  0.0  0.0  10080  2860 ?        Rs   23:00   0:00 sshd: root@pts/1
root      5045  0.0  0.0   4540  1416 pts/1    Ss   23:00   0:00 -bash
root      5491  0.1  0.0  58176 14836 ?        SN   23:30   0:00 /usr/bin/python -tt /usr/libexec/yum-updatesd-helper --check --dbus
root      5630  0.0  0.0   4260   952 pts/1    R+   23:32   0:00 ps -aux
[root@localhost lampp]# rpm -qa | grep MySQL
[root@localhost lampp]# rpm -qa | grep MySQL
[root@localhost lampp]# ls
bin      etc     lampp    licenses  php           sbin   var
cgi-bin  htdocs  lib      logs      phpmyadmin    share
error    icons   libexec  modules   RELEASENOTES  tmp
[root@localhost lampp]#
[root@localhost lampp]# ./lampp restrat
Usage: ./lampp <action>

        start        Start XAMPP (Apache, MySQL and eventually others)
        startapache  Start only Apache
        startssl     Start only SSL support
        startmysql   Start only MySQL
        startftp     Start only ProFTPD

        stop         Stop XAMPP (Apache, MySQL and eventually others)
        stopapache   Stop only Apache
        stopssl      Stop only SSL support
        stopmysql    Stop only MySQL
        stopftp      Stop only ProFTPD

        reload       Reload XAMPP (Apache, MySQL and eventually others)
        reloadapache Reload only Apache
        reloadmysql  Reload only MySQL
        reloadftp    Reload only ProFTPD

        restart      Stop and start XAMPP
        security     Check XAMPP's security

        php5         Activate PHP5
        phpstatus    Which version of PHP is active?

        backup       Make backup file of your XAMPP config, log and data files
        panel        Starts graphical XAMPP control panel

[root@localhost lampp]# ./lampp reload
XAMPP: Apache isn't running...
XAMPP: MySQL isn't running...
XAMPP: ProFTPD isn't running...
[root@localhost lampp]# ./lamp start
-bash: ./lamp: No such file or directory
[root@localhost lampp]#
[root@localhost lampp]# ./lampp start
Starting XAMPP for Linux 1.8.1...
XAMPP: Another web server daemon is already running.
XAMPP: Another MySQL daemon is already running.
XAMPP: Another FTP daemon is already running.
XAMPP for Linux started.
[root@localhost lampp]# sudo /etc/init.d/apache2 stop
sudo: /etc/init.d/apache2: command not found
[root@localhost lampp]# apache2 stop
-bash: apache2: command not found
[root@localhost lampp]#  netstat -lntp | grep :80
tcp        0      0 :::80                       :::*                        LISTEN      4570/httpd         
[root@localhost lampp]# kill  4570
[root@localhost lampp]#  netstat -lntp | grep :80
[root@localhost lampp]#  netstat -lntp | grep :mysql
[root@localhost lampp]#  netstat -lntp | grep mysql
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      4948/mysqld        
[root@localhost lampp]# kill  4948
[root@localhost lampp]#  netstat -lntp |grep   ftp
tcp        0      0 :::21                       :::*                        LISTEN      4989/proftpd: (acce
[root@localhost lampp]# kill   4989
[root@localhost lampp]# pwd
/opt/lampp
[root@localhost lampp]# ./lampp  start
Starting XAMPP for Linux 1.8.1...
XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for Linux started.
[root@localhost lampp]# #/etc/init.d/iptable stop                  
[root@localhost lampp]# chkconfig --level 35 iptables off  
[root@localhost lampp]# ./lampp  restart
Stopping XAMPP for Linux 1.8.1...
XAMPP: Stopping Apache with SSL...
XAMPP: Stopping MySQL...
XAMPP: Stopping ProFTPD...
XAMPP stopped.
Starting XAMPP for Linux 1.8.1...
XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for Linux started.
[root@localhost lampp]# ./lampp  stopssl
XAMPP: Stopping Apache with SSL...
XAMPP: Starting Apache...
[root@localhost lampp]# ./lampp  restart
Stopping XAMPP for Linux 1.8.1...
XAMPP: Stopping Apache...
XAMPP: Stopping MySQL...
XAMPP: Stopping ProFTPD...
XAMPP stopped.
Starting XAMPP for Linux 1.8.1...
XAMPP: Starting Apache...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for Linux started.
[root@localhost lampp]# ./lampp  restart
Stopping XAMPP for Linux 1.8.1...
XAMPP: Stopping Apache...
XAMPP: Stopping MySQL...
XAMPP: Stopping ProFTPD...
XAMPP stopped.
Starting XAMPP for Linux 1.8.1...
XAMPP: Starting Apache...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for Linux started.
[root@localhost lampp]# ./lampp  restart
Stopping XAMPP for Linux 1.8.1...
XAMPP: Stopping Apache...
XAMPP: Stopping MySQL...
XAMPP: Stopping ProFTPD...
XAMPP stopped.
Starting XAMPP for Linux 1.8.1...
XAMPP: Starting Apache...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for Linux started.
[root@localhost lampp]#

<think>嗯,用户展示了一个Linux终端提示符[root@localhost ~],并询问其用法和相关命令。这明显是Linux初学者在寻求基础操作指导。 用户可能刚接触Linux系统,需要从最基础的终端提示符结构开始理解。那个[root@localhost ~]其实包含三个关键信息:当前用户是root(管理员),主机名是localhost,当前目录是家目录~。这些信息对后续命令操作至关重要。 从引用内容看,用户似乎接触过一些基础命令(如uname、useradd配置),但需要系统化的操作指引。我应该先解释提示符含义,再分层次介绍常用命令:从目录导航开始,因为这是所有操作的基础;然后是核心操作命令(文件/进程/权限管理);最后是系统维护命令。这样符合学习路径。 特别注意要强调root账户的危险性——很多新手会忽略权限管理的安全风险。在示例命令中需要明确标注"危险操作"的警告,比如直接使用rm -rf这样的命令。 用户提供的引用材料里有很多实用信息点:引用1展示了进程分析和字符串提取的技巧,引用2详细说明了系统信息查询,引用3涉及用户配置。这些都可以融入相关命令的说明中,但要注意简化专业术语,避免让初学者困惑。 考虑到用户正在操作实体环境,应该优先介绍最常用且安全的命令(如ls/cd/pwd等),危险命令(如rm)必须附带明确警告。同时补充一些提高效率的小技巧,比如Tab补全、历史命令调用,这对新用户特别友好。</think>理解Linux终端提示符`[root@localhost ~]#`及其用法: 1. **提示符结构解析:** * `root`: 表示**当前登录的用户名**。这里是超级管理员`root`。 * `@`: 分隔符。 * `localhost`: 表示**当前计算机的主机名**。`localhost`是默认的本地主机名。 * `~`: 表示**当前工作目录**。`~`是用户家目录的简写(这里是`/root`)。 * `#`: 表示**命令提示符**。`#`通常表示当前用户具有**超级用户(root)权限**。普通用户的提示符通常是`$`。 2. **核心用途:** * 这个提示符是用户与Linux系统内核交互的**命令行界面(CLI)**。 * 用户在此输入命令,系统执行命令并返回结果或状态。 * 它是系统管理、文件操作、软件安装、网络配置等任务的核心工具。 3. **常用命令分类与示例:** **A. 导航与文件系统操作:** * `pwd`: 显示**当前工作目录**的完整路径。 ```bash [root@localhost ~]# pwd /root ``` * `ls`: **列出目录内容**。 * `ls -l`: 详细列表(权限、所有者、大小、时间)。 * `ls -a`: 显示所有文件(包括隐藏文件,以`.`开头)。 ```bash [root@localhost ~]# ls -la /etc ``` * `cd`: **切换目录**。 * `cd /path/to/dir`: 切换到绝对路径。 * `cd ..`: 切换到上级目录。 * `cd` 或 `cd ~`: 切换到当前用户的家目录。 ```bash [root@localhost ~]# cd /var/log [root@localhost log]# pwd /var/log [root@localhost log]# cd ~ [root@localhost ~]# pwd /root ``` * `mkdir`: **创建目录**。 ```bash [root@localhost ~]# mkdir my_new_directory ``` * `touch`: **创建空文件** 或 **更新文件时间戳**。 ```bash [root@localhost ~]# touch newfile.txt ``` * `cp`: **复制文件或目录**。 * `cp source destination`: 复制文件。 * `cp -r source_dir destination_dir`: 递归复制目录。 ```bash [root@localhost ~]# cp file1.txt /backup/ [root@localhost ~]# cp -r my_dir /backup/ ``` * `mv`: **移动文件或目录** 或 **重命名文件或目录**。 ```bash [root@localhost ~]# mv oldname.txt newname.txt # 重命名 [root@localhost ~]# mv file.txt /tmp/ # 移动 ``` * `rm`: **删除文件或目录**。 **(谨慎使用!)** * `rm file`: 删除文件。 * `rm -r directory`: 递归删除目录及其内容 **(危险)**。 * `rm -f file`: 强制删除,不提示确认 **(非常危险)**。 ```bash [root@localhost ~]# rm unwanted_file.txt [root@localhost ~]# rm -r old_directory/ # 删除目录需要 -r ``` * `cat`: **查看文件内容**、连接文件或从标准输入创建文件。 ```bash [root@localhost ~]# cat /etc/passwd ``` * `less` / `more`: **分页查看文件内容** (支持上下滚动搜索)。 ```bash [root@localhost ~]# less /var/log/messages ``` * `head` / `tail`: **查看文件开头/结尾部分**。 * `tail -f /path/to/logfile`: 实时跟踪查看日志文件新增内容。 ```bash [root@localhost ~]# tail -20 /var/log/secure # 查看最后20行 [root@localhost ~]# tail -f /var/log/httpd/access_log # 实时跟踪 ``` * `find`: **在目录树中查找文件**。 ```bash [root@localhost ~]# find / -name "*.conf" # 在根目录下查找所有.conf文件 [root@localhost ~]# find /var/log -mtime -1 # 在/var/log下查找1天内修改过的文件 ``` * `grep`: **在文件中搜索文本模式**。 ```bash [root@localhost ~]# grep "error" /var/log/messages # 在messages文件中搜索"error" [root@localhost ~]# ps aux | grep httpd # 在进程列表中搜索"httpd" ``` **B. 系统信息与管理:** * `uname`: **显示系统信息** (如引用[2]所示)。 * `uname -a`: 显示所有信息。 * `uname -s`: 内核名称。 * `uname -n`: 主机名。 * `uname -r`: 内核发行版本。 * `uname -m`: 硬件架构。 ```bash [root@localhost ~]# uname -a ``` * `top` / `htop`: **动态查看系统进程和资源使用情况** (CPU, 内存等)。`htop`是`top`的增强版。 * `ps`: **查看当前进程快照**。 * `ps aux`: 显示所有用户的详细进程信息。 ```bash [root@localhost ~]# ps aux | grep nginx ``` * `free` / `free -h`: **查看系统内存和交换空间使用情况** (`-h`以易读格式显示)。 ```bash [root@localhost ~]# free -h ``` * `df` / `df -h`: **查看磁盘空间使用情况** (`-h`以易读格式显示)。 ```bash [root@localhost ~]# df -h / ``` * `du` / `du -sh`: **查看目录或文件的磁盘使用情况** (`-s`汇总, `-h`易读)。 ```bash [root@localhost ~]# du -sh /var/log/ ``` * `systemctl`: **管理系统服务** (启动、停止、重启、启用开机启动、查看状态等)。 ```bash [root@localhost ~]# systemctl status httpd # 查看httpd服务状态 [root@localhost ~]# systemctl start nginx # 启动nginx服务 [root@localhost ~]# systemctl enable firewalld # 设置firewalld开机启动 ``` * `journalctl`: **查看和管理 systemd 日志**。 ```bash [root@localhost ~]# journalctl -u sshd # 查看sshd服务的日志 [root@localhost ~]# journalctl -f # 实时跟踪日志 ``` **C. 用户与权限管理:** * `useradd` / `adduser`: **添加用户** (配置参考引用[3]中的`/etc/login.defs`)。 ```bash [root@localhost ~]# useradd newuser ``` * `passwd`: **设置或修改用户密码**。 ```bash [root@localhost ~]# passwd newuser ``` * `usermod`: **修改用户属性** (如家目录、登录shell、主组、附加组等)。 ```bash [root@localhost ~]# usermod -s /bin/bash newuser ``` * `userdel`: **删除用户**。 * `userdel username`: 删除用户,保留家目录。 * `userdel -r username`: 删除用户并删除其家目录和邮件池 (行为受`USERDEL_CMD`和`USERGROUPS_ENAB`影响,见引用[3])。 ```bash [root@localhost ~]# userdel -r olduser ``` * `groupadd`: **添加用户组**。 ```bash [root@localhost ~]# groupadd newgroup ``` * `chmod`: **修改文件或目录的权限**。 * 符号模式: `chmod u=rwx,g=rx,o=r file` (用户=读写执行, 组=读执行, 其他=读) * 数字模式: `chmod 755 file` (rwxr-xr-x) ```bash [root@localhost ~]# chmod 644 important.conf ``` * `chown`: **修改文件或目录的所有者和/或所属组**。 ```bash [root@localhost ~]# chown newuser:newgroup file.txt [root@localhost ~]# chown :www-data /var/www/html/ # 只修改组 ``` * `su`: **切换用户**。 * `su - username`: 切换到指定用户,并加载其环境变量。 ```bash [root@localhost ~]# su - normaluser [normaluser@localhost ~]$ ``` * `sudo`: **以超级用户或其他用户身份执行命令**。 ```bash [normaluser@localhost ~]$ sudo yum update ``` **D. 网络管理:** * `ip` / `ifconfig` (较旧): **配置和查看网络接口信息**。 * `ip addr show`: 显示所有网络接口及其IP地址。 * `ip route show`: 显示路由表。 * `ping`: **测试网络连通性**。 ```bash [root@localhost ~]# ping -c 4 www.google.com ``` * `ss` / `netstat` (较旧): **查看网络连接、路由表、接口统计信息**。 ```bash [root@localhost ~]# ss -tuln # 查看监听中的TCP/UDP端口 ``` * `traceroute` / `tracepath`: **跟踪数据包到达目标主机的路径**。 * `curl` / `wget`: **从网络下载文件或测试Web服务**。 ```bash [root@localhost ~]# curl -I http://localhost # 获取HTTP响应头 [root@localhost ~]# wget http://example.com/file.iso ``` * `firewall-cmd`: **管理 firewalld 防火墙** (CentOS/RHEL/Fedora)。 ```bash [root@localhost ~]# firewall-cmd --list-all # 查看所有规则 [root@localhost ~]# firewall-cmd --add-service=http --permanent # 永久允许HTTP [root@localhost ~]# firewall-cmd --reload # 重载配置 ``` **E. 包管理 (根据发行版不同):** * **RHEL/CentOS/Fedora (dnf/yum):** * `dnf install package` / `yum install package`: 安装软件包。 * `dnf update package` / `yum update package`: 更新软件包。 * `dnf remove package` / `yum remove package`: 删除软件包。 * `dnf search keyword` / `yum search keyword`: 搜索软件包。 * `dnf info package` / `yum info package`: 查看软件包信息。 * **Debian/Ubuntu (apt):** * `apt update`: 更新可用软件包列表。 * `apt install package`: 安装软件包。 * `apt upgrade`: 升级所有可升级的软件包。 * `apt remove package`: 删除软件包 (保留配置文件)。 * `apt purge package`: 删除软件包及其配置文件。 * `apt search keyword`: 搜索软件包。 * `apt show package`: 查看软件包详细信息。 **F. 文本处理:** * `echo`: **输出文本**。 ```bash [root@localhost ~]# echo "Hello World" [root@localhost ~]# echo $PATH # 输出环境变量PATH的值 ``` * `vi` / `vim` / `nano`: **文本编辑器**。 * `sed`: **流编辑器,用于对文本进行过滤和转换**。 * `awk`: **强大的文本分析处理工具**。 * `sort`: **对文本行排序**。 * `wc`: **统计文件的行数、单词数、字节数**。 ```bash [root@localhost ~]# wc -l /etc/passwd # 统计passwd文件行数(用户数) ``` **G. 压缩与归档:** * `tar`: **打包和解包文件**。 * `tar -cvf archive.tar files/`: 创建归档文件。 * `tar -xvf archive.tar`: 解压归档文件。 * `tar -czvf archive.tar.gz files/`: 创建gzip压缩的归档文件。 * `tar -xzvf archive.tar.gz`: 解压gzip压缩的归档文件。 * `gzip` / `gunzip`: **压缩/解压单个文件** (`.gz`)。 * `zip` / `unzip`: **创建和解压 ZIP 归档文件**。 **H. 其他实用技巧:** * `history`: **查看命令历史记录**。 * `!number`: **执行历史记录中第`number`条命令**。 * `!!`: **执行上一条命令**。 * `clear`: **清屏** (或 `Ctrl+L`)。 * `Tab` 键: **命令/文件名/路径自动补全**。 * `Ctrl+C`: **终止当前正在运行的命令**。 * `Ctrl+D`: **发送EOF (End Of File),通常用于退出当前shell或结束输入)**。 * `Ctrl+Z`: **将当前前台命令挂起到后台** (使用`fg`恢复或`bg`后台运行)。 * `man command`: **查看命令的手册页(manual)** (最重要的帮助工具)。 ```bash [root@localhost ~]# man ls ``` * `command --help` 或 `command -h`: **查看命令的简要帮助信息**。 **重要提示:** * **谨慎使用 `root` 账户:** 提示符中的 `#` 表示你拥有最高权限。错误的命令(如 `rm -rf /`)可能造成灾难性后果。日常操作建议使用普通用户,仅在需要时使用 `sudo`。 * **理解命令参数:** 大多数命令都有丰富的选项(`-a`, `-l`, `-r` 等),使用 `man` 或 `--help` 查看其具体功能。 * **路径很重要:** 命令操作的对象(文件、目录)依赖于当前工作目录(`pwd`)或指定的绝对/相对路径。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值