---
title: "Linux学习笔记"
author: "elihe2011"
date: "2013-08-18T21:26:59Z"
tags: []
categories: ["操作系统"]
slug: "linux"
draft: false
lastmod: "2013-08-18T21:26:59Z"
id: 1901268
url: "https://elihe2011.iteye.com/blog/1901268"
---

env: 环境变量

set: 环境变量+用户自定义变量

 

 

PS1：提示符

csp:~ # echo $PS1  

\\h:\\w #

 

csp:~ # PS1='\[\\u@\\h \\W]\\$'

\[root@csp ~]#

 

\[root@csp ~]# PS1='\[\\u@\\h \\w \\A #\\#]\\$ '

\[root@csp ~ 17:14 #47]# 

 

$PS2 :第二提示符, 当需要额外输入的时候, 会看到它. 默认 "&gt;"

 

$$: 当前shell的PID

 

 

declare \[-aixr] variable

a: array

i: integer

x: export

r: readonly

 

eg:

sum=100+30+290

echo $sum    # 100+30+290

 

declare -i sum=100+30+290

echo $sum    # 420

 

 

\# 系统欢迎信息：

cat /etc/issue

 

\# 登入后的欢迎信息：

cat /etc/motd

 

 

\# bash环境配置：

1\) login shell，主要读取/etc/profile及~/.bash\_profile

2\) non-login shell，主要读取~/.bashrc

 

 

\# diff & cmp:

diff: 比较文本文件和目录

cmp：可以用于二进制文件，用byte比较

 

 

\# UID:

1\) 0, root

2\) 1~499，系统账号(/sbin/nonlogin)

3\) &gt; 500，一般账号

 

 

\# GID

\# 账号多组设置

usermod -G users developer  # 将developer用户加入组users，次要组

 

\# 用户所有组，返回的第一个组为有效组(effective group)，其他为初始组(initial group)

groups

 

\# 切换有效组，只对当前登录环境有效

newgrp users

 

 

\# 锁定和解锁用户

usermod -L developer

usermod -U developer

 

\# 查看密码参数，另外，可使用该命令去改变该账号的各种属性

chage -l developer

 

\# 当前系统上所有支持的shell

chsh -l

 

 

\# ACL, Access Control List