linux相关

##安装linux

###解决虚拟机中centos不能上网问题
1、首先将virtualbox设置为桥接网络,设置网卡为静态的,然后就可以了

1
2
3
4
5
6
7
8
9
10
11
设置IP和掩码
ifconfig eth0 192.168.5.40 netmask 255.255.255.0
最好编辑这个文件:
/etc/sysconfig/network-scripts/ifcfg-eth0 后面网卡可能不一样
设置网关
route add default gw 192.168.5.1
如果这样不行的话,永久修改网关
/etc/sysconfig/network 加入GATEWAY=192.168.1.1
vi /etc/resolv.conf
nameserver 8.8.8.8 #google域名服务器
nameserver 8.8.4.4 #google域名服务器

如设置命令行级别方法:
ln -sf /lib/systemd/system/runlevel3.target /etc/systemd/system/default.target

ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target

systemctl set-default multi-user.target
设置窗口级别方法:
ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

systemctl set-default graphical.target

如果每次开机之后丢失网络,需要手动每次把桥接网卡来回切换一下即可

###linux常用命令
1、查看占用端口
netstat –tunpl | grep 6379
2、查看某一个服务是否启动
ps –aux | grep redis
3、
/etc/init.d/redis-server stop
/etc/init.d/redis-server start
4、复制文件到远程服务器
scp /home/space/music/1.mp3 root@www.dzy.cn:/home/root/others/music/001.mp3
5、sudo : 暂时切换到超级用户模式以执行超级用户权限,提示输入密码时该密码为当前用户的密码,而不是超级账户的密码。不过有时间限制,Ubuntu默认为一次时长15分钟。
6、su : 切换到某某用户模式,提示输入密码时该密码为切换后账户的密码,用法为“su 账户名称”。如果后面不加账户时系统默认为root账户,密码也为超级账户的密码。没有时间限制。

Share