2016-09-17 18:54:40 +10:00
# You Don't Need GUI
< details >
It's for noobs :)
< / details >
Graphical user interfaces are super friendly to computer users. They were introduced in reaction to the perceived steep learning curve of command-line interfaces (CLIs).
![Xerox Star 8010 workstations ](./Xerox_Star_8010_workstations.jpg )
2016-09-18 17:39:18 +10:00
However, they often require more resources, are less powerful and hard to automate via scripting.
2016-09-17 18:54:40 +10:00
As a computer expert, we want to be more efficient and do our jobs better. We know that command words may not be easily discoverable or mnemonic, so we try to list some common tasks that you might tempt to do in GUI.
2016-09-18 10:42:02 +10:00
## Quick links
1. [copy a file ](#copyfile )
1. [duplicate a file ](#duplicatefile )
1. [copy a folder ](#copyfolder )
2016-09-18 17:39:18 +10:00
1. [duplicate a folder ](#duplicatefolder )
2016-09-18 10:42:02 +10:00
1. [move a file ](#movefile )
2016-10-16 00:13:32 +02:00
1. [rename a file ](#renamefile )
2016-09-18 10:42:02 +10:00
1. [move a folder ](#movefolder )
2017-01-11 15:08:13 +11:00
1. [rename a folder ](#renamefolder )
2016-11-16 12:16:04 +11:00
1. [create a new file ](#newfile )
1. [create a new folder ](#newfolder )
1. [show file/folder size ](#filesize )
1. [open a file with the default program ](#opendefault )
2016-09-18 10:42:02 +10:00
1. [zip a folder ](#zipfolder )
2016-11-16 12:16:04 +11:00
1. [unzip a folder ](#unzip )
2016-09-18 17:39:18 +10:00
1. [remove a file ](#removefile )
2016-09-18 10:42:02 +10:00
1. [remove a folder ](#removefolder )
1. [list folder contents ](#listfolder )
2016-11-12 00:20:38 +00:00
1. [tree view a folder and its subfolders ](#treeview )
2016-11-11 16:54:08 -06:00
1. [find a stale file ](#findfile )
1. [show a calendar ](#showcal )
2016-11-11 17:43:17 -06:00
1. [find a future date ](#calcdate )
2016-11-27 21:51:42 +11:00
1. [use a calculator ](#calculator )
2017-02-24 15:58:28 +11:00
1. [kill a program ](#killprogram )
2016-11-11 16:54:08 -06:00
2016-09-18 10:42:02 +10:00
## <a id="copyfile"></a>copy a file
2016-09-17 18:54:40 +10:00
**STOP DRAG AND DROP A FILE, OR CMD/CTRL + C, CMD/CTRL + V A FILE**
Copy `readme.txt` to the `documents` folder
```
2017-01-11 15:08:13 +11:00
cp readme.txt documents/
2016-09-17 18:54:40 +10:00
```
2016-09-18 10:42:02 +10:00
## <a id="duplicatefile"></a>duplicate a file
2016-09-17 20:22:03 +10:00
2016-11-16 12:16:04 +11:00
**STOP RIGHT CLICK AND DUPLICATE A FILE**
2016-09-17 20:22:03 +10:00
```
cp readme.txt readme.bak.txt
```
2016-09-18 10:42:02 +10:00
## <a id="copyfolder"></a>copy a folder
2016-09-17 18:54:40 +10:00
**STOP DRAG AND DROP A FOLDER, OR CMD/CTRL + C, CMD/CTRL + V A FOLDER**
2017-01-11 15:08:13 +11:00
Copy `myMusic` folder to the `myMedia` folder
2016-09-17 18:54:40 +10:00
```
2017-01-11 15:52:28 +11:00
cp -a myMusic myMedia/
# or
2017-01-11 15:08:13 +11:00
cp -a myMusic/ myMedia/myMusic/
2016-09-17 18:54:40 +10:00
```
2016-09-18 10:42:02 +10:00
## <a id="duplicatefolder"></a>duplicate a folder
2016-09-17 20:16:35 +10:00
2016-11-16 12:16:04 +11:00
**STOP RIGHT CLICK AND DUPLICATE A FOLDER**
2016-09-17 20:16:35 +10:00
```
2017-01-11 15:08:13 +11:00
cp -a myMusic/ myMedia/
2017-01-11 15:56:51 +11:00
# or if `myMedia` folder doesn't exist
cp -a myMusic myMedia/
2016-09-17 20:16:35 +10:00
```
2016-09-18 10:42:02 +10:00
## <a id="movefile"></a>move a file
2016-09-17 18:54:40 +10:00
**STOP DRAG AND DROP A FILE, OR CTRL + X, CTRL + V A FILE**
```
2016-11-15 19:55:34 -03:00
mv readme.txt documents/
2016-09-17 18:54:40 +10:00
```
2016-11-15 19:55:34 -03:00
**Always** use a trailing slash when moving files, [for this reason ](http://unix.stackexchange.com/a/50533 ).
2016-10-16 00:13:32 +02:00
## <a id="renamefile"></a>rename a file
**STOP RIGHT CLICK AND RENAME A FILE**
```
mv readme.txt README.md
```
2016-09-18 10:42:02 +10:00
## <a id="movefolder"></a>move a folder
2016-09-17 18:54:40 +10:00
**STOP DRAG AND DROP A FOLDER, OR CTRL + X, CTRL + V A FOLDER**
```
2017-01-11 15:52:28 +11:00
mv myMedia myMusic/
# or
2017-01-11 15:08:13 +11:00
mv myMedia/ myMusic/myMedia
```
## <a id="renamefolder"></a>rename a folder
**STOP RIGHT CLICK AND RENAME A FOLDER**
```
mv myMedia/ myMusic/
2016-09-17 18:54:40 +10:00
```
2016-11-16 12:16:04 +11:00
## <a id="newfile"></a>create a new file
2016-09-17 18:54:40 +10:00
**STOP RIGHT CLICK AND CREATE A NEW FILE**
```
touch 'new file'
```
2016-11-13 21:39:19 -02:00
or
```
> 'new file'
```
2016-09-17 18:54:40 +10:00
2016-11-16 12:16:04 +11:00
## <a id="newfolder"></a>create a new folder
2016-09-17 18:54:40 +10:00
**STOP RIGHT CLICK AND CREATE A NEW FOLDER**
```
mkdir 'untitled folder'
```
or
```
mkdir -p 'path/may/not/exist/untitled folder'
```
2016-11-16 12:16:04 +11:00
## <a id="filesize"></a>show file/folder size
2016-09-17 18:54:40 +10:00
**STOP RIGHT CLICK AND SHOW FILE/FOLDER INFO**
```
stat -x readme.md
```
2016-11-11 14:24:09 +05:30
or
```
du -sh readme.md
```
2016-11-16 12:16:04 +11:00
## <a id="opendefault"></a>open a file with the default program
2016-09-17 18:54:40 +10:00
**STOP DOUBLE CLICKING A FILE**
```
2016-11-06 20:50:12 +01:00
open file # on macOS
xdg-open file # on Linux
2016-09-17 18:54:40 +10:00
```
2016-09-18 10:42:02 +10:00
## <a id="zipfolder"></a>zip a folder
2016-09-17 18:54:40 +10:00
**STOP RIGHT CLICK AND COMPRESS FOLDER**
```
zip -r archive_name.zip folder_to_compress
```
2016-11-16 12:16:04 +11:00
## <a id="unzip"></a>unzip a folder
2016-09-17 18:54:40 +10:00
**STOP RIGHT CLICK AND UNCOMPRESS FOLDER**
```
unzip archive_name.zip
```
2016-09-18 10:42:02 +10:00
## <a id="removefile"></a>remove a file
2016-09-17 18:54:40 +10:00
2016-11-16 12:16:04 +11:00
**STOP RIGHT CLICK AND DELETE A FILE PERMANENTLY**
2016-09-17 18:54:40 +10:00
```
rm my_useless_file
```
2016-11-15 11:46:09 +11:00
IMPORTANT: The rm command deletes my_useless_file permanently, which is equivalent to move my_useless_file to Recycle Bin and hit Empty Recycle Bin.
2016-09-17 18:54:40 +10:00
2016-09-18 10:42:02 +10:00
## <a id="removefolder"></a>remove a folder
2016-09-17 18:54:40 +10:00
2016-11-16 12:16:04 +11:00
**STOP RIGHT CLICK AND DELETE A FOLDER PERMANENTLY**
2016-09-17 18:54:40 +10:00
```
2016-10-16 15:44:39 +02:00
rm -r my_useless_folder
2016-09-17 18:54:40 +10:00
```
2016-09-18 10:42:02 +10:00
## <a id="listfolder"></a>list folder contents
2016-09-17 18:54:40 +10:00
**STOP OPENING YOUR FINDER OR FILE EXPLORER**
```
ls -la my_folder
```
2016-11-12 00:20:38 +00:00
## <a id="treeview"></a>tree view a folder and its subfolders
2016-09-17 18:54:40 +10:00
2016-11-12 00:20:38 +00:00
**STOP OPENING YOUR FINDER OR FILE EXPLORER**
```
2016-11-11 21:48:25 -06:00
tree # on Linux
find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' # on macOS
2016-11-12 00:20:38 +00:00
```
2016-11-11 16:54:08 -06:00
## <a id="findfile"></a>find a stale file
**STOP USING YOUR FILE EXPLORER TO FIND A FILE**
Find all files modified more than 5 days ago
```bash
find my_folder -mtime +5
```
## <a id="showcal"></a>show a calendar
2016-11-11 17:47:29 -06:00
**STOP LOOKING UP WHAT THIS MONTH LOOKS LIKE BY CALENDAR WIDGETS**
2016-11-11 16:54:08 -06:00
2016-11-11 17:43:17 -06:00
Display a text calendar
2016-11-11 16:54:08 -06:00
```
cal
```
2016-11-11 17:43:17 -06:00
## <a id="calcdate"></a>find a future date
**STOP USING WEBAPPS TO CALCULATE FUTURE DATES**
What is todays date?
```
date +%m/%d/%Y
```
What about a week from now?
2016-11-11 21:39:40 -06:00
```bash
2016-11-11 21:48:25 -06:00
date -d "+7 days" # On Linux
date -j -v+7d # On MacOS
2016-11-11 17:43:17 -06:00
```
2016-11-27 21:51:42 +11:00
## <a id="calculator"></a>use a calculator
**STOP USING CALCULATOR WIDGET**
Want to use a calculator?
```
bc
```
2017-02-24 15:58:28 +11:00
## <a id="killprogram"></a>force quit a program
**STOP FORCE QUITE A PROGRAM USING GUI**
```
killall program_name
```
2016-11-12 09:58:25 +11:00
===
2016-09-18 18:16:37 +10:00
_Remember, you can always google or `man` the commands you are not familiar with._