Linux 入门基础(苏勇)课程笔记

这是网易云课堂上苏勇老师讲的Linux入门基础的笔记。笔记是在CentOS系统下记录的,只能用英文,可能单词的使用会有错误。笔记相对简单,基本上只记录了有关的命令操作,并没有关于原理性的知识。此笔记可以用作课程学习时的参考,也可在平时使用Linux时作为参考。

######################    Lesson 3 Basic Bash    ######################
hostname
uname (-a) (-all) (-r)
su -   (su root)
firefox &
history
!! (repeat last command)
!c (repeat last command start with character c)
!3 (repeat last command with number 3)
!?abc (repeat last command including "abc")
!-n (repeat command last but n)
Ctrl + r: search command in history
Esc -> . : repeat last paramater
-----------------------------------------
* (match one or more characters)
? (match only one characters)
[0-9] (match a number in this range)
[abc] (match any character in the square bracket [])
[^abc] (match character without those in square bracket [])
-----------------------------------------
su - ( switch user to root , creating a new terminal)
su ( switch user to root, not creating a new terminal )
sudo (excute with root user)
id
passwd
--------------- BASH  -------------------
& (background)
Ctrl + z : puse
Ctrl + c : stop
jobs
bg n (continue job n background)
fg n (continue job n frontground)


######################   Lesson 4    File System    ######################
pwd (current directory)
touch (create a blank file or update the time of a existed file)
ls -a (all file)
ls -l (details)
ls -R (sub directory)
ls -ls (details of a directory)

file (information of a file or a directory)

cd .. (parent directory)
cd . (current directory)
cd ~ (home directory)
cd   (home directory)
cd - (last directory)


######################   Lesson 5    File Operation   ######################
cp sourcefile targetfile (copy a file)
cp -r (copy a directory)
cp -v (display process)

mv (move and rename)

touch

rm (remove a file)
rm -r (remove a directory)
rm -i (interactive mode)
rm -f (compulsively)

mkdir (make a directory)
rmdir (remove a blank directory)


######################  Lesson 6  Linux System Directory  ######################
/bin  (binary, executable file, bash, command)
/boot 
/dev  (device, hardware -> file)
/etc  (configuration file)
/home (users home)
/lib  (library)
/lost+found
/media  (USB, etc)
/mnt  (old CD, etc)
/opt  (large software)
/proc (system real time message, in RAM)
    cat cpuinfo
    cat meminfo
    cat interrupts
    cat iomem
    cat uptime
    cat vmstat
    scsi
    acpi
/root (root user)
/sbin (super binary, only for root)
/selinux (secure)
/sys  (system, underlying hardware)
/tmp  (temporary)
/usr  (application software)
/var  (for variational information, log, mail etc)


######################  Lesson 7 Usual Command ######################

----- date and time -----
date (system time)
date -u  (UTC time)
date +%Y--%m--%d
date -s "20:20:20" (set time)

hwclock (clock)  (hardware clock)
cal  (calendar)
uptime  (system proceeding time)

----- print and view -----
echo  (print the input)
cat   (print file context)
head -n   (head lines)
tail -n   (tail lines)
     -f   (follow, usually for log)
more  (only page down)
less  (can page up and down)

----- view hardware information -----
lspci    (PCI device)
lspci -v (PCI device, details)
lsusb    (USB device)
lsusb -v (details)
lsmod    (mode, or drive named in Windows)

----- shut down and reboot -----
shutdown
shutdown -h (shut down)
shutdown -r (reboot)
e.g.
    shutdown -h now  (shut down now)
    shutdown -h +10  (shut down in 10 minutes)
    shutdown -h 23:20  (shut down at 23:20)
    shutdown -r now  (reboot now)
poweroff  (shut down now)
reboot    (reboot now)

----- file compress and archive -----
zip  targetfile.zip  sourcefile  (compress)
upzip  filename.zip
gzip linuxcast.net

tar -cvf out.tar linuxcast  (archive, not compress)
tar -xvf linuxcast.tar      (unarchive)
tar -cvzf backup.tar.gz /etc  (archive and compress, call gzip)

-----     search      -----
locate keyword  (search on database)
updatedb     (update datebase manually)

find  location  parameters
e.g.
    find . -name *keyname*
    fine / -name *.conf
    find / -perm 777   (permission 777)
    find / -type d  (d means directory)
    find / -type l  (l means link)
    find . -name "a*" -exec   ls -l   {} \;  (mus have {} \;)
#other parameters
 -namea
 -perm
 -user
 -group
 -ctime
 -type
 -size
    
	
######################   Lesson 8    Vi Text Editor  ######################
(another text editor: emacs, even better than vim)
# command mode (normal mode)
i  (insert at which cursor is)
o  (insert a new line below cursor)
dd (delete one line)
u  (undo, Ctrl+z) 
yy (copy current line)
n yy (n is a number, copy n lines)
r  (replace a character)
/  (find keywords, use "n" goto next)

# insert mode (input "i")

# ex mode (input ":")
:w  (save)
:q  (quit)
:q! (quit without saving)
:x  (save and quit)
:set number (or set nu, show line number)
:!  (excute a system command)
:sh (shell, return to command line, Ctrl+d return to vim)


######################   Lesson 9 Basic Concept Of Disk   ######################
all devices are files int directory /dev
device name: hd[a-z] (IDE device) , sd[a-z] (SATA, SCSI, SAS, USB, etc)

device name + partition name: 
e.g. sda1, sda2

partition method: MBR, GPT
MBR (Master Boot Record)  (Its traditional and old)
GPT (GUID Partition Table)


######################     Lesson 10 Using fdisk    ######################
fdisk /dev/sdb   (operation on sdb)
m (help)
p (print the partition table)
n (add a new partition)
  p (for primary partition)
  e (extended partition)
  
partprobe (update kernel info)
cat /proc/partitions (cat partitions info)


######################   Lesson 11   Linux File System   ######################
mke2fs -t ext4 /dev/sda3   (make a file system)
  -t (type)
  -b blocksize (system block size)
  -c (check)
  -L label  (label)
  -j (build system log)

mkfs (less parameters)
mkfs.ext3 /dev/sda1

dumpe2fs /dev/sda2 (see partition detail info)

e2label /dev/sda2  (print label)
e2label /dev/sda2 name (set label be name)

fsck /dev/sda2  (file system check)
  -y (do not display any hint and repair)
  -t (type, if damage is serious)
  (if a file is damage and there is no record, it will be put into lost+found directory)
  
  
######################    Lesson 12   Mount And Use File System    ######################
mount  /dev/sda3  /mnt   (mount sda3 to /mnt directory)
mount  (no parameter, print all mounted devices)
  -t   (type)
  -o   (option: ro,rw; sync; async; noatime; atime; remount)
e.g.
mount -o remount,sync /dev/sdb1 /mnt/

umount /dev/sda3
umount /mnt
fuser -m /mnt (see process that is using this device)
lsof /mnt   (list openfile, see which file is used)

#### auto mount ####
/etc/fstab is a file about auto mount
in every line (e.g. format):
/dev/sda3     /mnt      ext4    defaults  0 0
(device name; location; format; option;   dump fsck optiong)
(you can use label instead of sda3: LABEL=mylabel)
mount -a  (mount all device in fstab file)


######################  Lesson 13 Getting Help  ######################
-h or --help
man
man -k keyword   (file including keyword)
info    (much detailed)
	(using / to search)

(helping files are in /usr/share/doc)


######################   Lesson 14  Linux User Basic   ######################
/etc/passwd	(users information)
/etc/shadow	(users password)
/etc/group	(group information)

whoami
who
w

---------  create new user  ------------
useradd nash_su  (with copying /etc/skel to home directory)
passwd nash_su  (add password)
useradd -d
        -s
        -u
        -g
        -G

------- modify user ------
usermod -l newname oldname
	-u
	-d
	-g
	-G
	-L
	-U

-----  delete user ----
userdel name    (reserve home directory)
userdel -r name (delete home directory)


------  group  ---------
groupadd name
groupmod -n newname oldname
groupmod -g newGid  oldGid
groupdel name


######################   Lesson 15 Linux permission   ######################
chown username filename
      -R (change all files in this directory)
chgrp groupname filename
      -R

chmod mod filename   (e.g. u+rw  g-x  go+r  a-x)


######################  Lesson 16 Linux extended permission   ######################
umask [number]  (change umask)

----- special permission -----
chmod u+s filename  (set suid)
chmod g+s filename  (set sgid)
chmod o+t filename  (set sticky)


######################   Lesson 18 Internet Configration   ######################
ifconfig    (scan interface)
ifup eth0
ifdown eth0

setup

(network card: /etc/sysconfig/network-scripts/ifcfg-eth0)
(DNS:  /etc/resolv.conf)
(host name:  /etc/sysconfig/network)

ping  www.baidu.com (test connection)
host  www.baidu.com (test DNS)
dig   www.baidu.com (test DNS)
ip route  (print routing table)
tracerout www.baidu.com  (trace routing to destination)
mtr  www.baidu.com  (test network quality)

hostname traing.linuxcast.net (change hostname temporarily)
(/etc/sysconfig/network     change hostname permanently)


######################   Lesson 19 Linux Multy Task   ######################
Redirect:
>	(write to a file)
>>	(append to a file)
2>	(write stderr)
2>&1	(combine stdout and stderr)
<	(stdin)

Pipe:
|	(e.g. ls -l | grep keyword)


######################   Lesson 20 Text Processing   ######################
------ scan file -----
cat
more
less
head
tail

----- search keyword -----
grep -i
     -n
     -v
     -Ax
     -Bx

----- column mod -----
cut -d
    -f
    -c

----- text statistics -----
wc filename
   -l (line) 
   -w (word)
   -c (character)
   -m (sign)

----- sort file content -----
sort filename
     -r
     -n
     -f
     -u
     -t c
     -k x

uniq  (delete same lines)

----- compare text file -----
diff file1 file2
     -i
     -b
     -u

aspell

----- translate -----
tr -d 'keyword' < filename   (delete keyword)
tr 'a-z' 'A-Z' < filename   (translate a-z to A-Z)

----- search and substitue -----
sed 's/word1/word2/g' filename
sed '1,50s/word1/word2/g' filename
    -f 
	
	
######################   Lesson 21 Linux Boot   ######################
BIOS -> MBR -> GRUB -> KERNEL -> INIT
dmesg    (print kernel message)
runlevel (print runlevel)
init     (change runlevel)
grub-md5-crypt   (encipher passwd)


######################   Lesson 22 RPM Software Package   ######################
source install:
./configure
make
make install

rpm:
rpm -i software.rpm	(install)
rpm -e software		(uninstall)
rpm -U software-new.rpm	(update)
rpm ivh http://www.linuxcast.net/software.rpm	(install from Internet)
    -v
    -h

query:
rpm -qa		(all rpm software)
rpm -qf filename	(which package)
rpm -qi packagename	(its info)
rpm -ql packagename	(including files)
rpm -qip software.rpm	(its info)
rpm -qlp software.rpm	(including files)

verify:
rpm -K software.rpm
rpm -V software


######################   Lesson 23 YUM Software Package   ######################
/etc/yum/repos.d/
yum install software-name
yum remove software-name
yum update software-name

yum search keyword
yum list (all | installed | recent | updates)
yum info packagename
yum whatprovides filename

----- create repo manually -----
rpm -ivh createrepo-....rpm
createrepo ./path/
yum clean all

createrepo -g /tmp/*comps.xml /rpm-directory   (with group)
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值