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 )
1. [new file ](#newfile )
1. [new folder ](#newfolder )
1. [file/folder size ](#filesize )
1. [open a file with default program ](#opendefault )
1. [zip a folder ](#zipfolder )
2016-09-18 17:39:18 +10:00
1. [unzip ](#unzip )
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-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
```
cp readme.txt documents
```
2016-09-18 10:42:02 +10:00
## <a id="duplicatefile"></a>duplicate a file
2016-09-17 20:22:03 +10:00
**STOP RIGHT CLICK AND DUPLICATE FILE**
If `readme.bak.txt` file doesn't exist
```
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**
Copy `myMusic` folder under `myMedia` folder
```
2016-11-11 07:34:34 +01:00
cp -a myMusic myMedia
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
**STOP RIGHT CLICK AND DUPLICATE FOLDER**
If `myMedia` folder doesn't exist
```
2016-11-11 07:34:34 +01:00
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**
```
mv readme.txt documents
```
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**
```
mv myMedia myMusic
```
2016-09-18 10:42:02 +10:00
## <a id="newfile"></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-09-18 10:42:02 +10:00
## <a id="newfolder"></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-09-18 10:42:02 +10:00
## <a id="filesize"></a>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-09-18 10:42:02 +10:00
## <a id="opendefault"></a>open a file with 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-09-18 10:42:02 +10:00
## <a id="unzip"></a>unzip
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
**STOP RIGHT CLICK AND DELETE FILE OR DRAG IT TO RECYCLE**
```
rm my_useless_file
```
2016-09-18 10:42:02 +10:00
## <a id="removefolder"></a>remove a folder
2016-09-17 18:54:40 +10:00
**STOP RIGHT CLICK AND DELETE FOLDER OR DRAG IT TO RECYCLE**
```
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-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._