Permissions

Permissions

Here we will look at the essential part of system security and introduce the following command:
id:diplay user id
chmod:change a file’s mode
umask:set the default file permissions
su: run a shell as another user
chown:change a file’s owner
chgrp:change a file’s group ownership
passwd:change a user’s password

User accounts are defined in the /etc/passwd file.This file defines the username,uid,gid,the account’s real name,home directory and login shell
Groups are defined in the /etc/group file.

Reading,Writing and Executing

ls -l fool.txt

the first character means the type of the file/directory:
- -:a regular file
- d:directory
- l:a system link
- c:a character special file.It refers to a device that handles data as a stream of bytes.Sucn as terminal and moderm.
- b:a block special file,It refer s to a device that handles data in blocks.Such as hard-driver and CD-ROM drive.

umask-set default permissions

the umask command controls the default permissions given to a file when it is create.
the value of the umask is Oct and for example ,the value is 222,means the file don’t have the write permission with user/group/others.Where a 1 appears in the binary value,the corresponding attribute is unset.

su - run a shell with substitute user ans group IDs

su is used to start a shell as another user,the command pattern likes thie:

su [-[l]] [user]

if the ‘-l’ option is included,the resulting shell session is a login shell for the specified changed to the user’s environment.
If we want to start a shell with superuser,we can use:

su -

If we want to return to the previous user:

exit

sudo - execute a command as another user

sudo is just like su,but has some important addtional capabilities.sudo has been configured to allow us to run a fictitious backup program called backup_script with a superuser permission and does’t need to enter the password.in Ubuntu you can use it to execute the command with root right.

chown - change file owner and group

is used to change the owner/group of a file or directory,and need superuser permission.

chown [owner] [:[group]] file ...

Change your password

passwd [user]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值