Jiarui's Blog.

Notes for using Linux

2018/07/06 Share

chmod

1
chmod [options] mode[,mode] file1 [file2 ...]

Usual implemented options include:

-R recursive, i.e. include objects in subdirectories

-f force, forge ahead with all objects even if errors occur

-v verbose, show objects processed

1
2
3
$ ls -halF

drwxr-xr-x 1 root root 204 Jul 6 10:48 ./

前三个是user的权限,中间是group,最后是others。

使用方法

1
2
3
4
5
6
# 改变user的权限,使得user可以write和read
$ chmod u+rw ./
# 改变group和others的权限,使得group和others可以write和read
$ chmod go+rw ./
# 改变所有人的权限,使得所有人都可以write和read
$ chmod a+rwx ./

Reference:

https://en.wikipedia.org/wiki/Chmod

chown

1
$ sudo chown -R $USER: ./

multiprocessing

多进程加快程序运行。

1
2
3
4
5
6
7
8
from multiprocessing import Pool, cpu_count

def f(x):
return x*x

if __name__ == '__main__':
p = Pool(5)
print(p.map(f, [1, 2, 3]))

cpu_count可以看cpu数量。

可以通过htop查看thread数量。

tmux

1
2
tmux
tmux a

在ssh后,可以用tmux open a session,这样即使把terminal关了也可以挂着程序跑。

CATALOG
  1. 1. chmod
  2. 2. chown
  3. 3. multiprocessing
  4. 4. tmux