cheatsheets/linux.md

78 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2013-10-14 02:36:58 +00:00
---
title: Linux
---
### Read/Write/Execute a file
$ chmod +rwx App
$ ./App
### Remove
$ rm namefile
$ rm -d Directory
$ rm -rf Directory_with_files
### Copy file to a folder
$ cp namefile Downloads
$ ls
namefile Desktop Documents Downloads Music Pictures Public Templates Videos
$ cd Downloads
~/Downloads$ ls
namefile
### Create empty file
$ touch namefile
$ touch --help
### Show in the terminal the file
$ cat namefile
$ cat --help
### Create new directory
$ mkdir name
$ mkdir --help
### list files from directory
$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
$ ls --help
2012-03-16 06:14:31 +00:00
### Mounting a RAM drive
$ mount -t tmpfs -o size=5G,nr_inodes=5k,mode=700 tmpfs /tmp
2012-10-11 08:13:19 +00:00
### Visudo
sudo visudo
username ALL=(ALL) NOPASSWD:/sbin/restart whatever
2019-01-12 18:36:17 +00:00
### Display the amount of available disk space
2019-12-31 22:58:25 +00:00
```sh
df
df -h # human-readable format
df -a # all filesystems
```
2019-01-12 18:36:17 +00:00
2019-01-12 18:43:58 +00:00
### Display disk usage
2019-12-31 22:58:25 +00:00
```sh
du
du -hsx * | sort -rh | head -10 # largest 10 folders
```
2019-01-17 19:45:56 +00:00
### Answer yes in a bash script
2019-03-23 23:43:41 +00:00
```bash
yes | /your/command
```