Skip to content
Snippets Groups Projects

Update 3 files

Merged Fanny Wegner requested to merge master-patch-1968 into master
3 files
+ 64
2
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 53
0
# Bash Cheat Sheet
A cheat sheet for bash commands.
## Manage and navigate directories
```bash
pwd # Print current directory path
ls # List directories
ls -a|--all # List directories including hidden
ls -l # List directories in long form
ls -l -h|--human-readable # List directories in long form with human readable sizes
cd foo # Go to foo sub-directory
cd # Go to home directory
cd ~ # Go to home directory
cd - # Go to last directory
mkdir foo # Create foo directory
rmdir foo # Delete foo directory
rmdir -r foo # Delete foo directory including content
```
## Manage files
```bash
cp foo.txt bar.txt # Copy file
mv foo.txt bar.txt # Move/Rename file
rm foo.txt # Delete foo.txt
rm * # Delete all files in current directory
```
## Read and manipulate files
```bash
cat foo.txt # Print all contents
less foo.txt # Print some contents at a time (g - go to top of file, SHIFT+g, go to bottom of file, /foo to search for 'foo')
head foo.txt # Print top 10 lines of file
tail foo.txt # Print bottom 10 lines of file
nano foo.txt # Simple file editor
vi foo.txt # Advanced file editor
wc foo.txt # List number of lines words and characters in the file
```
## Input and Output
```bash
echo "Hello world!" # Print statement to standard output
echo "foo" > bar.txt # Direct output into file. Overwrites file if it already exists.
echo "foo" >> bar.txt # Direct output into file and append if it already exists.
command 1 | command2 # Directs output from command1 as standard input into command2
```
Loading