Linux 学习笔记--来自实验楼<1>

Linux 系统介绍

linux 基本概念及操作

shell 命令:

· echo "Hello world" ==> 每一种语言都有的打印hello world

<小技巧 , 当你忘记命令的时候 可以用Tab 去查看相关字母开头的所有命令>

· 无意中多输入了些命令,或者写错了。 可以用ctrl+c 去退出。 比如如下命令:


Allens-MacBook-Air:~ allenliu$ tail

^C

Allens-MacBook-Air:~ allenliu$

· 常用快捷键:

  • Ctrl+d 键盘输入结束或者退出

  • Ctrl+s 暂停当前程序

  • Ctrl+z 将程序放置到后台,恢复到前台的命令是fg

  • Ctrl+a 讲光标移动到行头

  • Ctrl+e 将光标移动到行尾

  • Ctrl+K 删除光标所在位置到行尾

  • Alt+ Backspace 向前删除一个单词

· 使用通配符

实际上相当于正则的用法。可以用* 跟 ? 来进行模糊匹配


Allens-MacBook-Air:desktop allenliu$ ls *.plist

QT0-NED.plist   QT0-NED_units_dictionary.plist

QT0-NED_units.plist QT0-NED_units_dictionary_modified.plist

Allens-MacBook-Air:desktop allenliu$

· 批量创建文件

touch 命令:


Allens-MacBook-Air:desktop allenliu$ touch Love_{1..2}_text.txt

Allens-MacBook-Air:desktop allenliu$

查看帮助

命令如下: man man

man 命令包括的主要区段如下

  1. 一般命令

  2. 系统调用

  3. 库函数,涵盖了C标准库

  4. 特殊文件和驱动程序

  5. 文件格式和约定

  6. 游戏和屏保

  7. 杂项

  8. 系统管理命令和守护进程


使用的具体方法:

Allens-MacBook-Air:desktop allenliu$ man 1 ls

LS(1)                    BSD General Commands Manual                    LS(1)

NAME

ls -- list directory contents

SYNOPSIS

ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file ...]

DESCRIPTION

For each operand that names a file of a type other than directory, ls

displays its name as well as any requested, associated information.  For

each operand that names a file of type directory, ls displays the names

of files contained within that directory, as well as any requested, asso-

ciated information.

Linux 用户及文件权限管理

用户管理

  1. 查看用户:

Allens-MacBook-Air:desktop allenliu$ who am i

allenliu ttys000  Oct  5 21:24

who 下面的常用参数:


Allens-MacBook-Air:desktop allenliu$ who -a

reboot  ~        Oct  5 20:57  .      1

allenliu console  Oct  5 20:58 00:56   107

allenliu ttys000  Oct  5 21:24  .    2384

.      run-level 3

Allens-MacBook-Air:desktop allenliu$ who -d

Allens-MacBook-Air:desktop allenliu$ who -m

allenliu ttys000  Oct  5 21:24

Allens-MacBook-Air:desktop allenliu$ who -q

allenliu allenliu

# users = 2

Allens-MacBook-Air:desktop allenliu$ who -u

allenliu console  Oct  5 20:58 00:57   107

allenliu ttys000  Oct  5 21:24  .    2384

Allens-MacBook-Air:desktop allenliu$ who -r

.      run-level 3

Allens-MacBook-Air:desktop allenliu$

  1. 创建用户

sudo 用来执行一些需要特权的命令,比如 adduser

su 用来切换用户

  1. Cat 命令

Cat 命令用来读取制定文件的内容把那个打印到终端输出, | sort 表示将读取的文本进行一个字典排序。


Allens-MacBook-Air:desktop allenliu$ cat /etc/group | sort

#

#

# Group Database

# Note that this file is consulted directly only when the system is running

# Open Directory.

# Open Directory.

# See the opendirectoryd(8) man page for additional information about

# in single-user mode.  At other times this information is provided by

##

##

_amavisd:*:83:

_appleevents:*:55:

_applepay:*:260:

_appowner:*:87:

_appserveradm:*:81:

_appserverusr:*:79:

_appstore:*:33:

_ard:*:67:

_assetcache:*:235:

_astris:*:245:

_atsserver:*:97:

_calendar:*:93:_teamsserver

_captiveagent:*:258:

_ces:*:32:

_clamav:*:82:

_coreaudiod:*:202:

_coremediaiod:*:236:

_ctkd:*:259:

_cvms:*:212:

_cvs:*:72:

· 删除用户


sudo deluser Allen --remove -home

文件权限

用较长的格式列出文件:


ls -l

image
image
image
image
iamge
iamge

· 变更文件所有者


cd /home/lilei

ls iphone6

sudo chown allen iphone6 ==> change ownship

cp iphone6 /home/allen ==> copy file

改变文件的权限

  1. 二进制表示:

每个文件有三种权限,(拥有者,所属用户组,其他用户)。每组权限都对应着一个r'w'x。也就是如图所示的7

image
image

echo "echo \"hello world\"" >iphone6

chmod 700 iphone6

2, 另外一种方式是:加减赋权的方法

g->group

o->other

u->user

对于文件还可以这样


chmod go -rw iphone

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Ubuntu的发音 Ubuntu,源于非洲祖鲁人和科萨人的语言,发作 oo-boon-too 的音。了解发音是有意...
    萤火虫de梦阅读 100,330评论 9 468
  • linux资料总章2.1 1.0写的不好抱歉 但是2.0已经改了很多 但是错误还是无法避免 以后资料会慢慢更新 大...
    数据革命阅读 13,028评论 2 33
  • (一)基本命令 命令格式: 命令 参数 1.ls 显示文件名,等同于dos下dir命令 命令格式:ls [opti...
    飞羽孟德阅读 2,050评论 0 3
  • 轻轻拨开发梢, 点燃窖藏了一旬的酝酿, 在微醺的清晨, 悄悄的绽放, 朗姆味的琉璃, 软软的靠在树上, 躺在湖上,...
    茗香酒影阅读 219评论 0 1
  • 这是今天读《把时间当作朋友》时的一个感悟,书里李笑来用自己亲身经历的两个例子说明了一个事实:就同一个原因,人有可能...
    何二的李斯阅读 322评论 0 0

友情链接更多精彩内容