ubuntu 学习计划:第一节

准备:
1.VMware
2.ubuntu镜像

一,安装:
1. VMware下载后一路next
2. 在vm中新建一个虚拟机(可以全使用默认设置)
3. 在vm选择已经下载的ubuntu镜像
4. 等待vm将镜像按照好后,设置用户信息就可以直接登录。

二、练习
Q1.创建两个用户lily和tom,指定用户默认目录在/home/下。lily允许远程登录,tom不允许远程登录
Q2.创建文件夹/home/tom/temp 改变文件夹的权限为可读写执行,将文件夹的所属用户改为lily

A1:

root@jay:/mnt# useradd -d /home/ -s /bin/sh lily

root@jay:/mnt# passwd lily
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
//lily登录
$ ls
test_finder  tuser1  

-s /bin/sh 用户不能使用tab补全命令
-s /bin/bash 可以tab补全命令

root@jay:/mnt# useradd -d /usr/sam -s /bin/sh -m san
//san登录
$ ls
examples.desktop
$ cd ..
$ ls
bin    d    home        lib64       mnt   root  srv  usr
boot   dev  initrd.img  lost+found  opt   run   sys  var
cdrom  etc  lib         media       proc  sbin  tmp  vmlinuz

$ cd ..
$ ls
bin  games  include  lib  local  sam  sbin  share  src
root@jay:useradd tom
//tom登录
$ ls
bin    d    home        lib64       mnt   root  srv  usr
boot   dev  initrd.img  lost+found  opt   run   sys  var
cdrom  etc  lib         media       proc  sbin  tmp  vmlinuz
root@jay:/# userdel lily
root@jay:/# userdel tom


root@rwang:/# useradd wwww
//登录后根目录,home中无wwww文件夹
root@rwang:/home# useradd -d /home/lily -s /bin/bash lily
//登录后依然是根目录,home中依然没有lily文件夹,但是:

这里写图片描述

下面重新创建tom

root@jay:/home# adduser tom
Adding user `tom' ...
Adding new group `tom' (1006) ...
Adding new user `tom' (1004) with group `tom' ...
Creating home directory `/home/tom' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for tom
Enter the new value, or press ENTER for the default
        Full Name []: tom
        Room Number []: none
        Work Phone []: none
        Home Phone []: none
        Other []: none
Is the information correct? [Y/n] y

这里写图片描述
(path 中有不同的命令 path和 用户后的*/bash就是用户使用命令的配置)

用tom登录,直接进入/home/tom

查看tom的信息:

root@jay:/home# awk '{if(match($1,"tom")) print($0)}' /etc/passwd
tom:x:1004:1006:tom,none,none,none,none:/home/tom:/bin/bash

保存这个结果到特定文件中:

root@jay:/home# awk '{if(match($1,"tom")) print($0)}' /etc/passwd | cat > /home/FileName

tom不允许远程登录:需要将/etc/passwd中的tom用户信息改为:

tom:x:1004:1006:tom,none,none,none,none:/home/tom:/sbin/nologin

A2:

tom@inch:~$ mkdir temp
tom@inch:~$ ls -l
total 16
-rw-r--r-- 1 tom tom 8980 Jul 28 01:25 examples.desktop
drwxrwxr-x 2 tom tom 4096 Jul 28 02:28 temp


lily@inch:~$ ls /home/tom/ -l
total 16
-rw-r--r-- 1 tom tom 8980 Jul 28 01:25 examples.desktop
drwxrwxr-x 2 tom tom 4096 Jul 28 02:28 temp



root@inch:/home/tom# ls
examples.desktop  temp
root@inch:/home/tom# chown lily temp
root@inch:/home/tom# ls -l
total 16
-rw-r--r-- 1 tom  tom 8980 Jul 28 01:25 examples.desktop
drwxrwxr-x 2 lily tom 4096 Jul 28 02:28 temp


lily@inch:~$ chmod 777 /home/tom/temp
lily@inch:~$ ls -l /home/tom
total 16
-rw-r--r-- 1 tom  tom 8980 Jul 28 01:25 examples.desktop
drwxrwxrwx 2 lily tom 4096 Jul 28 02:28 temp

查看文件信息
root@ubuntu:/home/test_finder# ls -author a.txt
-rw-r–r– 1 root 5 Jul 22 01:59 a.txt
修改文件权限:
root@ubuntu:/home/test_finder# chmod 666 a.txt
root@ubuntu:/home/test_finder# ls -author a.txt
-rw-rw-rw- 1 root 5 Jul 22 01:59 a.txt
参考:修改linux文件权限命令:chmod (作者Avril)

思考:创建文件夹、文件的方式:

文件夹:

root@ubuntu:/usr/local# cd /home/
root@ubuntu:/home# mkdir first_Dic
root@ubuntu:/home# ls
first_Dic  tuser1  
root@ubuntu:/home# mkdir second_Dic third_dic forth fifth
root@ubuntu:/home# ls
fifth      forth  second_Dic  third_dic first_Dic  tuser1
root@ubuntu:/home# rm second_Dic third_dic forth fifth
rm: cannot remove ‘second_Dic’: Is a directory
rm: cannot remove ‘third_dic’: Is a directory
rm: cannot remove ‘forth’: Is a directory
rm: cannot remove ‘fifth’: Is a directory
root@ubuntu:/home# rm -r second_Dic third_dic forth fifth
root@ubuntu:/home# ls
first_Dic  rwang  thinkjoy  tuser1  zhiliao
root@ubuntu:/home#

lily@inch:~$ mkdir /home/lily/{lib,local,net,log}
lily@inch:~$ ls /home/lily/
examples.desktop  lib  local  log  net

文件:

lily@inch:~/lib$ ls
lily@inch:~/lib$ touch a b c.log d.txt f.bmp
lily@inch:~/lib$ ls
a  b  c.log  d.txt  f.bmp

lily@inch:~/lib$ touch {q,w,e,r,t}.zip
lily@inch:~/lib$ ls
a  b  c.log  d.txt  e.zip  f.bmp  q.zip  r.zip  t.zip  w.zip
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值