OSDN Git Service

Regular updates
[twpd/master.git] / linux.md
1 ---
2 title: Linux
3 layout: 2017/sheet
4 ---
5
6 ### Read/Write/Execute a file
7
8     $ chmod +rwx App
9     $ ./App
10
11 ### Remove
12
13     $ rm namefile
14     $ rm -d Directory
15     $ rm -rf Directory_with_files
16
17 ### Copy file to a folder
18
19     $ cp namefile Downloads
20     $ ls
21     namefile  Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
22     $ cd Downloads
23     ~/Downloads$ ls
24     namefile
25
26
27 ### Create empty file
28
29     $ touch namefile
30     $ touch --help
31
32 ### Show in the terminal the file
33
34     $ cat namefile
35     $ cat --help
36
37
38 ### Create new directory
39
40     $ mkdir name
41     $ mkdir --help
42
43 ### list files from directory
44
45     $ ls
46     Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
47     $ ls --help
48
49 ### Mounting a RAM drive
50
51     $ mount -t tmpfs -o size=5G,nr_inodes=5k,mode=700 tmpfs /tmp
52
53 ### Visudo
54
55     sudo visudo
56
57     username ALL=(ALL) NOPASSWD:/sbin/restart whatever
58
59 ### Display the amount of available disk space
60
61 ```sh
62 df
63 df -h   # human-readable format
64 df -a   # all filesystems
65 ```
66
67 ### Display disk usage
68
69 ```sh
70 du
71 du -hsx * | sort -rh | head -10    # largest 10 folders
72 ```
73
74 ### Answer yes in a bash script
75
76 ```bash
77 yes | /your/command
78 ```