OSDN Git Service

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