很多人最先使用的台式机操作系统都是windows,对macos和linux的文件系统可能感到难以理解。计算机使用的存储介质是磁盘,文件系统是用来组织管理磁盘内容的。
你可以先这样简单地记忆,windows中表示一个文件的位置时使用下面的样式,c:\a\b.txt(其中符号c是某块磁盘的记号)。 linux中表示一个文件的位置时使用下面的样式,/a/b/c.txt(无论文件在那块磁盘上,只要这个样式不会重复就ok)。后面你会慢慢理解一些。


1, linux相关的一些命令
whatis <command> 显示简短功能描述
man [<chapter>] <command>   查看命令的介绍
一般一个命令会提供 <command> -h 或 <command> --help ,用来说明命令用法。
查看登陆时使用的用户信息, who am i
修改文件所有者 chown <用户名> <被修改文件>
使用root权限执行命令,sudo <command>
修改用户的登陆密码: passwd <username>

2,解析DNS

apt install bind9
apt install dnsutils
nslookup www.baidu.com
host www.baidu.com
dig www.baidu.com

 

 3.ssh 命令远程登录

首先说明一下环境,我用的ubuntu kylin16.04 ukui

先修改/etc/ssh/sshd_config文件中PermitRootLogin yes这表示可以用密码登录root

然后sudo service  sshd restart

(ubuntu 中没有/etc/init.d/sshd 或者 /etc/rc.d/sshd)

客户端运行 ssh ip地址 -l root

出现错误Connection reset by ip地址 port 22

重启sshd、ssh、重启电脑都不管用,

于是我sudo apt remove openssh-server 

sudo apt install openssh-server

再ssh登录就成功了。

 

 

4,ubuntu 挂载windows分区(NTFS)

http://wiki.ubuntu.com.cn/%E6%8C%82%E8%BD%BDWindows%E5%88%86%E5%8C%BA

ubuntu对NFTS的支持为只读;linux分区信息在/dev目录下;一般将设备媒体挂在到/media目录下

fdisk -l可以列出电脑上的分区,回想一下windows系统中才c、d、e各个盘的容量,就大概知道那个是c盘,哪个是e盘了。

mount /dev/sda1 /media/win8/diskc -t ntfs -o nls=utf8,umask=0222 挂在c盘到/media/win8/diskc,机器重启后并没有再次挂载c盘;

开机可以挂载windows的方法,修改配置文件/etc/fstab添加/dev/sda1 /media/win8/diskc  ntfs utf8,umask=0222 0 0

使用mount -a挂载/etc/fstab中提到的全部分区使配置立即生效,这方法机器重启后还会挂载windows磁盘。

感觉在linux里不管干点什么都要改一下配置文件。。。要是那一天改错了怎么办!

 

5,一些linux目录

linux是一类系统的统称,存在很多不同版本的linux系统,它们的某些配置文件路径可能有所不同

/etc是配置文件;

/tmp 临时文件;

/home用户目录;

/root超级用户目录;

lib库文件;

/usr全称Unix Shared Resources共享资源目录;

/etc/default/grub 引导配置文件             案例:修改grub默认引导项,修改GRUB_DEFAULT=2                sudo vim /etc/default/grub                  update-grub

/etc/apt/source.lst apt-get软件源

/etc/passwd 登录名:X:用户标识号:组标志号:全名或其他:主目录:登陆shell

/etc/shadow 用户名、密码、有效期等信息 

/etc/fstab 要挂载的分区信息

 

 

6,一个错觉引发的血案

再让自己明确一下这几个概念:info、warning、error;

warning 不是error!!

安装Redis,参考的官网

http://www.redis.cn/download.html

https://maintao.com/2015/redis-up-and-running/

开始很顺利,wget url

tar xzf *.tar.gz

cd redis*

make

创建Redis服务:

 sudo mkdir /etc/redis

sudo cp  redis.config /etc/redis/6001.conf

sudo vi /etc/redis/6001.conf

daemonize yes

pidfile /var/run/redis_6001.pid

port  6001

logfile /var/log/redis_6001.log

dir /var/redis/6001

sudo mkdir /var/redis/6001

然后设置开机自启动:

sudo cp utils/redis_init_script /etc/init.d/redis_6001

sudo vim /etc/init.d/redis_6001

REDISPORT 6001

最后关键的一步:sudo update-rc.d redis_6001 defaults

resserv:warnning: ...... missing LSB tags and va...

输出明显和网页上的示例不一致,当时没多想,以为又是什么地方出错了,还安慰自己,万事开头难。。。

鼓捣了一上午,还换了一个3.2.8稳定版本,还是一样。

最后使用自动化脚本安装sudo utils/install_server.sh

居然是一样的提示,于是乎明白了什么,默默重启一下电脑,发现redis6001端口服务已经启动了。

再次注意warning 不是error!!!

收获:LSB: linux standard base 

run level :运行级别

init.d 系统启动时可能用到

sudo update-rc.d name remove取消开机启动

pidfile:来自Stack OverFlow---A Pid-File is a file containing the process identification number (pid) that is stored in a well-defined location of the filesystem thus allowing other programs to find out the pid of a running script.

没有绝对正确的教程,实际工作时的环境总是有所差别,遇事冷静!