我的学习笔记(二)

1.复制某文件夹内所有文件到另一个文件夹

cp -Rf  /import/*  /home/node4

将import内所有文件复制到node4


2./bin与/usr/bin的区别

/bin 二进制可执行命令
/sbin 系统管理命令,这里存放的是系统管理员使用的管理程序
/usr/bin 众多的应用程序
/usr/sbin 超级用户的一些管理程序


3.如果系统不认识某个命令,可以通过yum whatprovides 搜索安装包并安装


4. fdisk可以配置MBR格式; gdisk配置gpt格式, parted可以自己选择


5.ssh是你链接别人用的 配置文件是ssh_conf

ssh server是别人链接你用的,配置文件是sshd_conf


6.crontab 添加定时任务使用脚本需要用绝对路径


7.ll显示的是字节,可以使用-h参数来提高文件大小的可读性,另外ll不是命令,是ls -l的别名


8.挂载windows共享文件夹

mount -t cifs -o username=administrator,password=dddddd //192.168.12.1/note /note

mount -t cifs -o user=jimmy,password='abc!222' //192.168.1.4/迅雷下载 /mnt/test

如果密码里含有特殊符号时,记得前后加上单引号,如'pass!word'

否则,会报如下错误

-bash: !222: event not found


9.很多Linux distribution使用udev动态管理设备文件,并根据设备的信息对其进行持久化命名
一般来说 , 对应关系应该记录在 /etc/udev/rules.d/70-persistent-net.rules

10.查看某端口被什么程序占用

netstat -alp |grep 5900

或者程序使用了哪些端口

netstat -alp |grep vnc


11.关闭防火墙

centos 7:
systemctl stop firewalld.service #停止
systemctl disable firewalld.service #禁用
之前的版本:
service iptables stop #停止
chkconfig iptables off #禁用

12.关闭selinux

vi /etc/sysconfig/selinux

SELINUX=disabled

centos7的文件路径有些许变化,如下:

vi /etc/selinux/config



13.结束某个进程或任务

a.  

ps aux 查看PID

kill -9 1348


b.

jobs 查看后台任务

[root@bainuo ~]# jobs
[1]+  Stopped                 find a.txt /

[root@bainuo ~]# kill %1


[1]+  Stopped                 find a.txt /


14.centos7设置主机名

hostnamectl set-hostname centos7.test.com

记得再编辑一下hosts文件


15.快速对应物理网卡与系统网卡编号

比如当你无法确认eth0对应的是哪块网卡时,一般都是通过插拔网线来确认的吧,反正我是这么干过

其实可以通过以下命令快速识别

ethtool --identify eth0 20

这个命令的意思就是让eth0的网卡灯亮20秒

还有一个选项

ethtool -p eth0 20

意思是让eth0的网卡灯闪20秒,哪块网卡的灯在闪,哪块就对应eth0


16.查看文件行数

wc -l /etc/abc.conf //显示该文件有多少行

-c以字节数显示,-w以字数显示


17.使用cat合并文件

cat a.txt >> b.txt //把a.txt的内容追加到b.txt后面

cat a.txt > b.txt //用a.txt的内容覆盖b.txt的内容



18. ~/的含义

~代表你的主目录,例如你的用户名为tom,那么~/代表/home/tom/


19.FTP架设

http://blog.csdn.net/kepa520/article/details/77444113

http://blog.csdn.net/kepa520/article/details/47022459

http://blog.csdn.net/kepa520/article/details/77448557

http://blog.csdn.net/kepa520/article/details/77448568

http://blog.csdn.net/kepa520/article/details/77480016


20.查看服务器报错情况

grep error /var/log/messages


21.SecureFX显示隐藏文件

勾选view---Dot files

22.简易http服务器搭建

yum install httpd -y
service httpd start
chkconfig httpd on

网页文件默认存放目录/var/www/html

创建文件进行测试

vi /var/www/html/index.html


一些相关设置参数:

Apache主配置文件:/etc/httpd/conf/httpd.conf
ServerRoot "/etc/httpd" #用于指定Apache的运行目录
Listen 80 # 监听端口
User apache #运行apache程序的用户和组
Group apache
ServerAdmin root@localhost #管理员邮箱
DocumentRoot "/var/www/html" #网页文件的存放目录
<Directory "/var/www/html"> #<Directory>语句块自定义目录权限
Require all granted
</Directory>
ErrorLog "logs/error_log" #错误日志存放位置
AddDefaultCharset UTF-8 #默认支持的语言
IncludeOptional conf.d/*.conf #加载其它配置文件
DirectoryIndex index.html #默认主页名称


进阶设置:

http://blog.csdn.net/kepa520/article/details/77555414

http://blog.csdn.net/kepa520/article/details/77559496



23.MySQL相关文章

http://blog.csdn.net/kepa520/article/details/77559496

http://blog.csdn.net/kepa520/article/details/77564290

http://blog.csdn.net/kepa520/article/details/77561839

http://blog.csdn.net/kepa520/article/details/77559770



24.NFS服务器简易搭建

yum install nfs-utils -y

service rpcbind start //centos6之前的版本此服务名为portmap

service nfs start //centos7中服务名为nfs-server

chkconfig rpcbind on

chkconfig nfs on

编辑配置文件

vi /etc/sysconfig/nfs

在文末添加如下内容:

LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
RQUOTAD_PORT=875
MOUNTD_PORT=892
STATD_PORT=662
STATD_OUTGOING_PORT=2020
RPCNFSDARGS="-N 4"

创建输出文件夹

mkdir /data

chown 65534.65534 data //65534为默认的匿名用户和匿名组的ID

编辑输出目录配置文件

vi /etc/exports

/data *(rw,sync,no_subtree_check,all_squash) //anonuid和anongid未指定的话,默认为65534

service nfs restart


客户端挂载测试

临时挂载

[root@centos7 mnt]# mount -t nfs 192.168.1.20:/data /mnt/nfs
mount: 文件系统类型错误、选项错误、192.168.1.20:/data 上有坏超级块、
缺少代码页或助手程序,或其他错误
(对某些文件系统(如 nfs、cifs) 您可能需要
一款 /sbin/mount.<类型> 助手程序)

有些情况下在 syslog 中可以找到一些有用信息- 请尝试
dmesg | tail 这样的命令看看。
[root@centos7 mnt]# yum install nfs-utils -y //出现上面这种报错的话,需要安装一下nfs

如果挂载成功后,没有写入权限的话,那就是服务器端权限配置有问题,需重新检查


建议的永久挂载方式:

vi /etc/fstab

192.168.1.20:/data /mnt/nfs nfs soft,intr,rsize=8192,wsize=8192 0 0

mount -a


http://blog.csdn.net/kepa520/article/details/51027701

http://blog.csdn.net/kepa520/article/details/50222295

http://blog.csdn.net/kepa520/article/details/51027748

http://blog.csdn.net/kepa520/article/details/77619254


25.samba服务器简易配置

yum install samba -y

[root@bainuo ~]# service smb start
启动 SMB 服务:                                            [确定]
[root@bainuo ~]# service nmb start
启动 NMB 服务:                                            [确定]

[root@bainuo ~]# chkconfig smb on
[root@bainuo ~]# chkconfig nmb on
vi /etc/samba/smb.conf

security = share

load printers = no

注释掉默认的home和printers

增加

[test]
comment = test
path = /test
writable = yes
browseable = yes
guest ok = yes

printable = no

[root@bainuo samba]# testparm //使用此命令检查配置文件是否有误
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[test]"
WARNING: The security=share option is deprecated
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
workgroup = MYGROUP
server string = Samba Server Version %v
security = SHARE
log file = /var/log/samba/log.%m
max log size = 50
client signing = required
idmap config * : backend = tdb
comment = All Printers
path = /var/spool/samba
printable = Yes
print ok = Yes
cups options = raw
browseable = No

[test]
comment = test
path = /test
read only = No
guest ok = Yes
browseable = Yes

loaded service file OK.说明配置文件没有问题

service smb restart;service nmb restart

chown -R nobody:nobody /test   //否则匿名用户没有写入权限

然后就可以用客户端访问测试一下。

win客户端比较简单

linux客户端如下:

 yum install samba-client
[root@centos7 ~]# smbclient -L 192.168.1.20 -N  //查看samba共享,-N意为不需要密码
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-44.el6_9]

        Sharename       Type      Comment
        ---------       ----      -------
        test            Disk      test
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-44.el6_9]

        Server               Comment
        ---------            -------
        BAINUO               Samba Server Version 3.6.23-44.el6_9

        Workgroup            Master
        ---------            -------
        MYGROUP              BAINUO
[root@centos7 ~]# smbclient //192.168.1.20/test -N   //连接到samba
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-44.el6_9]
Server not using user level security and no password supplied.
smb: \> ?
临时挂载方法

[root@centos7 mnt]# mount -t cifs //192.168.1.20/test /mnt/smb
mount: 文件系统类型错误、选项错误、//192.168.1.20/test 上有坏超级块、
       缺少代码页或助手程序,或其他错误
       (对某些文件系统(如 nfs、cifs) 您可能需要
       一款 /sbin/mount.<类型> 助手程序)

       有些情况下在 syslog 中可以找到一些有用信息- 请尝试
       dmesg | tail  这样的命令看看。
如果出现以上错误
yum install cifs-utils
[root@centos7 mnt]# mount -t cifs //192.168.1.20/test /mnt/smb
Password for root@//192.168.1.20/test:  
如果不想跳出输密码的步骤,如下

[root@centos7 ~]# mount -t cifs //192.168.1.20/test /mnt/smb -o guest
其中-t cifs意义为使用SMB文件系统,-o guest意义为匿名访问,即使用guest来宾账户,之后不会再要求输入密码。命令执行完毕后即将远程主机上的Public目录挂载到本地的/mnt/samba目录。

开机自动挂载方法:

vi /etc/fstab

//192.168.1.20/test    /mnt/smb                 cifs    guest        0 0
如果是有用户名密码的呢,方法如下

//192.168.1.20/test    /mnt/smb                 cifs    username=abc,password=123456        0 0

相关文章:

http://blog.csdn.net/kepa520/article/details/77631160

http://blog.csdn.net/kepa520/article/details/77629636



26.关于dig 命令查看域名的解析过程:

dig www.xxx.com +trace

27.有时候ssh连接很慢,是因为开启了dns反向查询,关闭即可

[root@test ~]# vi /etc/ssh/sshd_config
找到#UseDNS  yes 去掉注释,将yes改为no

重启sshd服务即可


28.DNS简易搭建

http://blog.csdn.net/kepa520/article/details/77906018



猜你喜欢

转载自blog.csdn.net/kepa520/article/details/50296687
今日推荐