linux心得及命令

心得:用xshell,xftp登陆的那个ip地址是公网的ip地址
    yum install ... 这个命令是在线安装应用的
    记得将java的jdk和tomcat解压在/usr/local路径下

1:which是用来查看一个文件是否存在,若存在就返回该文件所在的路径,返回的是执行路径,find返回的是安装路径,如下所示
[root@izumce51w0ruacz ~]# which tomcat
/usr/sbin/tomcat

2:cd是进入一个目录,ls是显示这个目录下的所有文件,如下所示
[root@izumce51w0ruacz ~]# cd /usr/sbin
[root@izumce51w0ruacz sbin]# ls
accessdb                   grub2-install               postcat
addgnupghome               grub2-mkconfig              postconf
addpart                    grub2-ofpathname            postdrop
adduser                    grub2-probe                 postfix
agetty                     grub2-reboot                postkick
aliyun_installer           grub2-rpm-sort              postlock
aliyun-service             grub2-set-default           postlog
aliyun-service.backup      grub2-setpassword           postmap
alternatives               grub2-sparc64-setup         postmulti
anacron                    grubby                      postqueue
applygnupgdefaults         gshelld                     postsuper
arp                        halt                        poweroff
arpd                       hardlink                    ppp-watch
arping                     hwclock                     pwck
atd                        iconvconfig                 pwconv
atrun                      iconvconfig.x86_64          pwhistory_helper
audispd                    ifcfg                       pwunconv
auditctl                   ifconfig                    rdisc
auditd                     ifdown                      readprofile
augenrules                 ifenslave                   reboot
aureport                   ifstat                      redhat_lsb_trigger.x86_64
ausearch                   ifup                        resize2fs
authconfig                 init                        resizepart
authconfig-tui             insmod                      restorecon
autrace                    install-info                rmmod
avcstat                    installkernel               route
badblocks                  intel-microcode2ucode       routef
biosdecode                 ip                          routel
biosdevname                ip6tables                   rsyslogd
blkdeactivate              ip6tables-restore           rtacct
blkdiscard                 ip6tables-save              rtcwake
blkid                      ipmaddr                     rtmon
blockdev                   iprconfig                   rtpr
bridge                     iprdbg                      rtstat
btrfs                      iprdump                     runlevel
btrfsck                    iprinit                     runuser
btrfs-convert              iprsos                      sasldblistusers2
btrfs-debug-tree           iprupdate                   saslpasswd2
btrfs-find-root            ipset                       sefcontext_compile
btrfs-image                iptables                    selabel_digest
btrfs-map-logical          iptables-restore            selabel_lookup
btrfs-select-super         iptables-save               selabel_lookup_best_match
btrfstune                  iptunnel                    selabel_partial_match
btrfs-zero-log             irqbalance                  selinuxconlist
build-locale-archive       kdump                       selinuxdefcon
cacertdir_rehash           kexec                       selinuxenabled
capsh                      killall5                    selinuxexeccon
cbq                        kpartx                      selinux_restorecon
cfdisk                     lchage                      semodule
chcpu                      ldattach                    sendmail
chkconfig                  ldconfig                    sendmail.postfix
chpasswd                   lgroupadd                   service
chronyd                    lgroupdel                   sestatus
chroot                     lgroupmod                   setcap
clock                      lid                         setenforce
clockdiff                  lnewusers                   setfiles
consoletype                lnstat                      setsebool
cracklib-check             load_policy                 sfdisk
cracklib-format            logrotate                   shutdown
cracklib-packer            logsave                     slattach
cracklib-unpacker          losetup                     sln
create-cracklib-dict       lpasswd                     smtp-sink
crond                      lpc                         smtp-source
ctrlaltdel                 lpc.cups                    ss
ctstat                     lsmod                       sshd
debugfs                    luseradd                    sshd-keygen
delpart                    luserdel                    sulogin
depmod                     lusermod                    sushell
devlink                    makedumpfile                swaplabel
dhclient                   matchpathcon                swapoff
dhclient-script            mii-diag                    swapon
dmfilemapd                 mii-tool                    switch_root
dmidecode                  mkdict                      sysctl
dmsetup                    mkdumprd                    sys-unconfig
dmstats                    mke2fs                      tc
dracut                     mkfs                        tcpdump
dumpe2fs                   mkfs.btrfs                  tcpslice
e2freefrag                 mkfs.cramfs                 telinit
e2fsck                     mkfs.ext2                   tickadj
e2image                    mkfs.ext3                   tomcat
e2label                    mkfs.ext4                   tracepath
e2undo                     mkfs.minix                  tracepath6
e4defrag                   mkfs.xfs                    tune2fs
eapol_test                 mkhomedir_helper            tuned
ebtables                   mklost+found                tuned-adm
ebtables-restore           mkswap                      udevadm
ebtables-save              modinfo                     unix_chkpwd
ecs_mq_rps_rfs             modprobe                    unix_update
eni-ifscan                 nameif                      update-alternatives
eni-version                netreport                   useradd
ether-wake                 NetworkManager              userdel
ethtool                    new-kernel-pkg              usermod
faillock                   newusers                    usernetctl
fdformat                   nl-class-add                vigr
fdisk                      nl-class-delete             vipw
filefrag                   nl-classid-lookup           virt-what
findfs                     nl-class-list               virt-what-cpuid-helper
firewalld                  nl-cls-add                  visudo
fixfiles                   nl-cls-delete               vmcore-dmesg
fsck                       nl-cls-list                 vpddecode
fsck.btrfs                 nl-link-list                weak-modules
fsck.cramfs                nl-pktloc-lookup            wipefs
fsck.ext2                  nl-qdisc-add                wpa_cli
fsck.ext3                  nl-qdisc-delete             wpa_passphrase
fsck.ext4                  nl-qdisc-list               wpa_supplicant
fsck.minix                 nologin                     xfs_admin
fsck.xfs                   nscd                        xfs_bmap
fsfreeze                   nstat                       xfs_copy
fstrim                     ntpd                        xfs_db
fuser                      ntpdate                     xfs_estimate
fxload                     ntpdc                       xfs_freeze
genhomedircon              ntp-keygen                  xfs_fsr
genhostid                  ntpq                        xfs_growfs
genl                       ntptime                     xfs_info
genl-ctrl-list             ownership                   xfs_io
getcap                     packer                      xfs_logprint
getenforce                 pam_console_apply           xfs_mdrestore
getpcaps                   pam_tally2                  xfs_metadump
getsebool                  pam_timestamp_check         xfs_mkfile
glibc_post_upgrade.x86_64  parted                      xfs_ncheck
groupadd                   partprobe                   xfs_quota
groupdel                   partx                       xfs_repair
groupmems                  pidof                       xfs_rtcp
groupmod                   ping6                       xtables-multi
grpck                      pivot_root                  zdump
grpconv                    plipconfig                  zic
grpunconv                  plymouthd                   zramctl
grub2-bios-setup           plymouth-set-default-theme
grub2-get-kernel-settings  postalias

3:加上./就找到startup.sh了,不加就没找到
[root@izumce51w0ruacz bin]# startup.sh
-bash: startup.sh: command not found
[root@izumce51w0ruacz bin]# ./startup.sh
Using CATALINA_BASE:   /usr/local/apache-tomcat-8.5.27
Using CATALINA_HOME:   /usr/local/apache-tomcat-8.5.27
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.5.27/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/apache-tomcat-8.5.27/bin/bootstrap.jar:/usr/local/apache-tomcat-8.5.27/bin/tomcat-juli.jar
Tomcat started.


4:解压缩的命令,tar zxvf + 名字,如下所示
[root@izumce51w0ruacz local]# tar zxvf apache-tomcat-8.5.27.tar.gz

5:只写cd是返回顶层的命令,cd ..注意中间有个空格这是返回上一层的命令,直接ls不能显示文件数量,只有先cd /才能显示文件数量(相当于桌面的文件数量),如下所示
[root@izumce51w0ruacz /]# cd
[root@izumce51w0ruacz ~]# cd /
[root@izumce51w0ruacz /]# ls
bin   etc        jdk-9.0.4_linux-x64_bin.tar.gz  lost+found  opt   run   sys  var
boot  home       lib                             media       proc  sbin  tmp
dev   jdk-9.0.4  lib64                           mnt         root  srv   usr


6:用cd的时候如果下一层还是文件夹,那么就可以直接写文件夹的名字,如果是文件的话,就必须写成./+文件名的形式,不然找不到,vi+文件名是用来编辑文件的,记得按了回车后再按一下i,在这里i表示插入的意思,编辑好之后按一下esc表示退出编辑模式,然后输入:wq,表示保存并关闭文件,部分代码如下所示
[root@izumce51w0ruacz bin]# cd ..
[root@izumce51w0ruacz apache-tomcat-8.5.27]# cd logs
[root@izumce51w0ruacz logs]# catalina.out
-bash: catalina.out: command not found
[root@izumce51w0ruacz logs]# ./catalina.out
-bash: ./catalina.out: Permission denied
[root@izumce51w0ruacz logs]# cd ..
[root@izumce51w0ruacz apache-tomcat-8.5.27]# cd conf
[root@izumce51w0ruacz conf]# vi ./server.xml


7:一个网上的博客
解决 linux 的 bash:vi:command not find
转载 2017年07月03日 10:31:24 2398
   Linux命令行输入命令执行后报“bash:vi:command not found”这是由于系统PATH设置问题,PATH没有设置对,系统就无法找到精确命令了。
           1、在命令行中输入:export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin  这样可以保证命令行命令暂时可以使用。命令执行完之后先不要关闭终端。
     2、在命令行中输入 vi /etc/profile 查看是否自己另外设置了PATH属性。         
                 在Vi编辑器中输入
             export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin
    我的linux系统是由于设置pig环境变量时设置PATH属性导致command not found错误,所以我本机的PATH属性设置如下:
    export JAVA_HOME="/usr/local/Java/jdk1.6.0_45"
   export CLASSPATH=".:/usr/local/java/jdk1.6.0_45/lib:/usr/local/java/jdk1.6.0_45/jre/lib"
   pathmunge /usr/local/java/jdk1.6.0_45/bin:/usr/local/java/jdk1.6.0_45/jre/bin:/usr/local/pig-0.9.2/bin

  export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
    3、保存profile,执行source ~/.etc/profile,是profile生效,然后测试下vi命令,执行成功。


8:find查找命令的用法
[root@izumce51w0ruacz ~]# find / -name java
/jdk-9.0.4/bin/java
/var/lib/alternatives/java
/etc/alternatives/java
/etc/pki/ca-trust/extracted/java
/etc/pki/java
/etc/java
/usr/share/java
/usr/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java
/usr/lib/java

9:source命令是配置玩环境变量后使用的,使用之后就可以生效
[root@izumce51w0ruacz bin]# source /etc/profile

10:mkdir创建文件夹
[root@izumce51w0ruacz usr]# mkdir java
[root@izumce51w0ruacz usr]# cd java
[root@izumce51w0ruacz java]# mkdir packages


11:mv移动文件指令的用法,先进入要移动文件的文件夹下,然后写文件名及目的路径
[root@izumce51w0ruacz bin]# cd /usr/java/packages/lib
[root@izumce51w0ruacz lib]# mv tomcat-native-1.2.7-src /jdk-9.0.4/lib


12:rpm -qa|grep java用来查看系统中有几个javajdk,rpm -e --nodeps+名字是用来移除jdk的
[root@izumce51w0ruacz ~]# rpm -qa|grep java
python-javapackages-3.4.1-11.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
tzdata-java-2017c-1.el7.noarch
javamail-1.4.6-8.el7.noarch
[root@izumce51w0ruacz ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.161-0.b14.el7_4.x86_64


13:直接运行vi+文件名,如果文件不存在,将会自动创建
vi server.xml


14:echo把一个文本写进一个文件中,如果这个文件不存在就会自动创建一个
[root@izumce51w0ruacz ~]# echo Tomcat test > /data/wwwroot/default/index.jsp


15:rm -rf + 文件夹名,将文件夹及其下面的文件都删除
[root@iZumce51w0ruacZ /]# rm -rf data

你可能感兴趣的:(linux心得及命令)