diff options
| author | srdusr <[email protected]> | 2023-01-05 18:23:47 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2023-01-05 18:23:47 +0200 |
| commit | 34cef1e8e80fd3765a8766e2763f1c18cb2a83bd (patch) | |
| tree | ad788797d192c4df26f9ae0250b40f472f0828b6 | |
| parent | 41a046896b2e7b4bfa5f7c1071eadcb3cac46bbb (diff) | |
| download | notes-34cef1e8e80fd3765a8766e2763f1c18cb2a83bd.tar.gz notes-34cef1e8e80fd3765a8766e2763f1c18cb2a83bd.zip | |
Recall the Previous Command
| -rw-r--r-- | linux/linux-commands.md | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/linux/linux-commands.md b/linux/linux-commands.md index 52695f1..39caeae 100644 --- a/linux/linux-commands.md +++ b/linux/linux-commands.md @@ -18,14 +18,27 @@ NOTE: `.` can also be used but is limited `$ cp -r $(pwd)/path-to/file ~/new/path/` `$ mv -r ~/another/directory/file .` - - - - #### Copying/Pasting Text -- Copy text/output into a file (useful if in putty/non graphical terminal emulator) - `$ <command> 2>&1 | tee output-file` +- Copy text/output of a command into a file (useful if in putty/non graphical terminal emulator) + `$ <command> 2>&1 | tee -a output.txt` or - `$ echo "text" 2>&1 | tee output-file` # print text without executing a command + `$ echo "text" 2>&1 | tee -a output.txt` # print text without executing a command +- - - + +#### Recall the Previous Command +- Use `!!` to express the last command + For example if a command needs root permissions: + ```bash + $ touch /opt/file.txt + touch: cannot touch '/opt/file.txt': Permission denied + $ sudo !! + sudo touch /opt/file.txt + [sudo] password for user: + $ ls -l /opt/myFile.txt + -rw-r--r-- 1 root root 0 Dec 21 16:20 /opt/file.txt + ``` - - - #### Getting information about a window |