2016-09-17 18:54:40 +10:00
# You Don't Need GUI
2019-11-15 09:42:20 +11:00
[![Join the community on Spectrum ](https://withspectrum.github.io/badge/badge.svg )](https://spectrum.chat/you-dont-need/GUI)
2016-09-17 18:54:40 +10:00
< details >
It's for noobs :)
< / details >
2017-04-08 10:59:32 +10:00
< br / >
2016-09-17 18:54:40 +10:00
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
2018-04-28 14:44:29 +09:30
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 be tempted to do in GUI.
2016-09-17 18:54:40 +10:00
2016-09-18 10:42:02 +10:00
## Quick links
2017-11-17 17:35:58 +11:00
1. [copy a file ](#copy-a-file )
1. [duplicate a file ](#duplicate-a-file )
1. [copy a folder ](#copy-a-folder )
1. [duplicate a folder ](#duplicate-a-folder )
1. [move a file ](#move-a-file )
1. [rename a file ](#rename-a-file )
1. [move a folder ](#move-a-folder )
1. [rename a folder ](#rename-a-folder )
1. [merge folders ](#merge-folders )
1. [create a new file ](#create-a-new-file )
1. [create a new folder ](#create-a-new-folder )
2017-11-17 17:36:33 +11:00
1. [show file/folder size ](#show-filefolder-size )
2017-11-17 17:35:58 +11:00
1. [open a file with the default program ](#open-a-file-with-the-default-program )
1. [zip a folder ](#zip-a-folder )
1. [unzip a folder ](#unzip-a-folder )
1. [remove a file ](#remove-a-file )
1. [remove a folder ](#remove-a-folder )
1. [list folder contents ](#list-folder-contents )
1. [tree view a folder and its subfolders ](#tree-view-a-folder-and-its-subfolders )
1. [find a stale file ](#find-a-stale-file )
1. [show a calendar ](#show-a-calendar )
1. [find a future date ](#find-a-future-date )
1. [use a calculator ](#use-a-calculator )
2017-11-17 17:37:29 +11:00
1. [force quit a program ](#force-quit-a-program )
2018-11-06 14:00:32 +05:30
1. [check server response ](#check-server-response )
2018-11-06 13:29:41 +05:30
1. [view content of a file ](#view-content-of-a-file )
2018-10-25 11:58:42 +05:30
1. [search for a text ](#search-for-a-text )
2018-11-19 15:12:07 +11:00
1. [view an image ](#view-an-image )
2018-12-13 01:19:58 +11:00
1. [show disk size ](#show-disk-size )
2018-12-13 16:04:49 +11:00
1. [check performance of your computer ](#check-performance-of-your-computer )
2018-11-14 11:20:28 +11:00
1. [Quick tips ](#quick-tips )
2018-11-14 11:59:53 +11:00
1. [Hotkeys ](#hotkeys )
2017-11-17 17:35:58 +11:00
## copy a file
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP DRAG AND DROPING A FILE, OR CMD/CTRL + C, CMD/CTRL + V A FILE** :-1:
2016-09-17 18:54:40 +10:00
Copy `readme.txt` to the `documents` folder
2017-06-07 14:48:44 +10:00
```shell
2017-01-11 15:08:13 +11:00
cp readme.txt documents/
2016-09-17 18:54:40 +10:00
```
2017-11-17 17:35:58 +11:00
## duplicate a file
2016-09-17 20:22:03 +10:00
2018-11-22 15:06:08 +11:00
**STOP RIGHT CLICKING AND DUPLICATE A FILE** :-1:
2016-09-17 20:22:03 +10:00
2017-06-07 14:48:44 +10:00
```shell
2016-09-17 20:22:03 +10:00
cp readme.txt readme.bak.txt
```
2017-11-17 17:35:58 +11:00
## copy a folder
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP DRAG AND DROPING A FOLDER, OR CMD/CTRL + C, CMD/CTRL + V A FOLDER** :-1:
2016-09-17 18:54:40 +10:00
2017-01-11 15:08:13 +11:00
Copy `myMusic` folder to the `myMedia` folder
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
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
```
2017-11-17 17:35:58 +11:00
## duplicate a folder
2016-09-17 20:16:35 +10:00
2018-11-22 15:06:08 +11:00
**STOP RIGHT CLICKING AND DUPLICATE A FOLDER** :-1:
2016-09-17 20:16:35 +10:00
2017-06-07 14:48:44 +10:00
```shell
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
```
2017-11-17 17:35:58 +11:00
## move a file
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP DRAG AND DROPING A FILE, OR CMD/CTRL + X, CMD/CTRL + V A FILE** :-1:
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
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 ).
2017-11-17 17:35:58 +11:00
## rename a file
2016-10-16 00:13:32 +02:00
2018-11-22 15:06:08 +11:00
**STOP RIGHT CLICKING AND RENAME A FILE** :-1:
2016-10-16 00:13:32 +02:00
2017-06-07 14:48:44 +10:00
```shell
2016-10-16 00:13:32 +02:00
mv readme.txt README.md
```
2017-11-17 17:35:58 +11:00
## move a folder
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP DRAG AND DROPING A FOLDER, OR CMD/CTRL + X, CMD/CTRL + V A FOLDER** :-1:
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
2017-01-11 15:52:28 +11:00
mv myMedia myMusic/
# or
2017-01-11 15:08:13 +11:00
mv myMedia/ myMusic/myMedia
```
2017-11-17 17:35:58 +11:00
## rename a folder
2017-01-11 15:08:13 +11:00
2018-11-22 15:06:08 +11:00
**STOP RIGHT CLICKING AND RENAME A FOLDER** :-1:
2017-01-11 15:08:13 +11:00
2017-06-07 14:48:44 +10:00
```shell
2017-01-11 15:08:13 +11:00
mv myMedia/ myMusic/
2016-09-17 18:54:40 +10:00
```
2017-11-17 17:35:58 +11:00
## merge folders
2017-02-25 08:26:01 +11:00
2018-11-22 15:06:08 +11:00
**STOP DRAG AND DROPING TO MERGE FOLDERS** :-1:
2017-02-25 08:26:01 +11:00
2017-06-07 14:48:44 +10:00
```shell
2017-02-25 08:26:01 +11:00
rsync -a /images/ /images2/
```
2017-11-17 17:35:58 +11:00
## create a new file
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP RIGHT CLICKING AND CREATE A NEW FILE** :-1:
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
2019-04-05 10:53:00 +01:00
touch 'new file' # updates the file's access and modification timestamp if it already exists
2017-06-07 14:48:44 +10:00
# or
2019-04-05 10:53:00 +01:00
> 'new file' # erase the content if it already exists
2016-11-13 21:39:19 -02:00
```
2016-09-17 18:54:40 +10:00
2017-11-17 17:35:58 +11:00
## create a new folder
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP RIGHT CLICKING AND CREATE A NEW FOLDER** :-1:
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
2016-09-17 18:54:40 +10:00
mkdir 'untitled folder'
2017-06-07 14:48:44 +10:00
# or
2016-09-17 18:54:40 +10:00
mkdir -p 'path/may/not/exist/untitled folder'
```
2017-11-17 17:35:58 +11:00
## show file/folder size
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP RIGHT CLICKING AND SHOW FILE/FOLDER INFO** :-1:
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
2016-09-17 18:54:40 +10:00
stat -x readme.md
2017-06-07 14:48:44 +10:00
# or
2016-11-11 14:24:09 +05:30
du -sh readme.md
```
2017-11-17 17:35:58 +11:00
## open a file with the default program
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP DOUBLE CLICKING ON A FILE** :-1:
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
2016-11-06 20:50:12 +01:00
xdg-open file # on Linux
2017-06-07 14:48:44 +10:00
open file # on MacOS
2016-09-17 18:54:40 +10:00
```
2017-11-17 17:35:58 +11:00
## zip a folder
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP RIGHT CLICKING AND COMPRESS FOLDER** :-1:
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
2016-09-17 18:54:40 +10:00
zip -r archive_name.zip folder_to_compress
```
2017-11-17 17:35:58 +11:00
## unzip a folder
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP RIGHT CLICKING AND UNCOMPRESS FOLDER** :-1:
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
2016-09-17 18:54:40 +10:00
unzip archive_name.zip
```
2017-11-17 17:35:58 +11:00
## remove a file
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP RIGHT CLICKING AND DELETE A FILE PERMANENTLY** :-1:
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
2016-09-17 18:54:40 +10:00
rm my_useless_file
```
2017-06-07 14:48:44 +10:00
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
2017-11-17 17:35:58 +11:00
## remove a folder
2016-09-17 18:54:40 +10:00
2018-11-22 15:06:08 +11:00
**STOP RIGHT CLICKING AND DELETE A FOLDER PERMANENTLY** :-1:
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
2016-10-16 15:44:39 +02:00
rm -r my_useless_folder
2016-09-17 18:54:40 +10:00
```
2017-11-17 17:35:58 +11:00
## list folder contents
2016-09-17 18:54:40 +10:00
2017-11-17 16:59:51 +11:00
**STOP OPENING YOUR FINDER OR FILE EXPLORER** :-1:
2016-09-17 18:54:40 +10:00
2017-06-07 14:48:44 +10:00
```shell
2016-09-17 18:54:40 +10:00
ls -la my_folder
```
2017-06-07 14:48:44 +10:00
2017-11-17 17:35:58 +11:00
## tree view a folder and its subfolders
2016-09-17 18:54:40 +10:00
2017-11-17 16:59:51 +11:00
**STOP OPENING YOUR FINDER OR FILE EXPLORER** :-1:
2016-11-12 00:20:38 +00:00
2017-06-07 14:48:44 +10:00
```shell
2016-11-11 21:48:25 -06:00
tree # on Linux
2017-06-07 14:48:44 +10:00
find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' # on MacOS
2016-11-12 00:20:38 +00:00
```
2017-06-07 14:48:44 +10:00
2017-11-17 17:35:58 +11:00
## find a stale file
2016-11-11 16:54:08 -06:00
2017-11-17 16:59:51 +11:00
**STOP USING YOUR FILE EXPLORER TO FIND A FILE** :-1:
2016-11-11 16:54:08 -06:00
Find all files modified more than 5 days ago
2017-06-07 14:48:44 +10:00
```shell
2016-11-11 16:54:08 -06:00
find my_folder -mtime +5
```
2017-11-17 17:35:58 +11:00
## show a calendar
2016-11-11 16:54:08 -06:00
2017-11-17 16:59:51 +11:00
**STOP LOOKING UP WHAT THIS MONTH LOOKS LIKE BY CALENDAR WIDGETS** :-1:
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
2017-06-07 14:48:44 +10:00
```shell
2016-11-11 16:54:08 -06:00
cal
```
2018-10-02 21:12:45 -03:00
Display selected month and year calendar
```shell
cal 11 2018
```
2016-11-11 16:54:08 -06:00
2017-11-17 17:35:58 +11:00
## find a future date
2016-11-11 17:43:17 -06:00
2017-11-17 16:59:51 +11:00
**STOP USING WEBAPPS TO CALCULATE FUTURE DATES** :-1:
2016-11-11 17:43:17 -06:00
What is todays date?
2017-06-07 14:48:44 +10:00
```shell
2016-11-11 17:43:17 -06:00
date +%m/%d/%Y
```
What about a week from now?
2017-06-07 14:48:44 +10:00
```shell
date -d "+7 days" # on Linux
date -j -v+7d # on MacOS
2016-11-11 17:43:17 -06:00
```
2017-11-17 17:35:58 +11:00
## use a calculator
2016-11-27 21:51:42 +11:00
2017-11-17 16:59:51 +11:00
**STOP USING CALCULATOR WIDGET** :-1:
2016-11-27 21:51:42 +11:00
2017-06-07 14:48:44 +10:00
```shell
2016-11-27 21:51:42 +11:00
bc
```
2017-11-17 17:35:58 +11:00
## force quit a program
2017-02-24 15:58:28 +11:00
2018-11-28 15:50:50 +11:00
**STOP CTRL + ALT + DELETE and choose the program to kill** :-1:
2017-02-24 15:58:28 +11:00
2017-06-07 14:48:44 +10:00
```shell
2017-02-24 15:58:28 +11:00
killall program_name
```
2018-11-06 14:00:32 +05:30
## check server response
2018-11-22 15:06:08 +11:00
**STOP OPENING A BROWSER** :-1:
2018-11-06 14:00:32 +05:30
```shell
2018-11-19 15:12:07 +11:00
ping umair.surge.sh
2018-11-06 14:00:32 +05:30
```
2018-11-06 13:29:41 +05:30
## view content of a file
2018-11-22 15:06:08 +11:00
**STOP DOUBLE CLICKING A FILE** :-1:
2018-11-06 13:29:41 +05:30
```shell
2018-11-19 15:12:07 +11:00
cat apps/settings.py
2018-11-06 13:29:41 +05:30
```
2018-10-25 11:58:42 +05:30
## search for a text
2018-11-22 15:06:08 +11:00
**STOP CMD/CTRL + F IN A FOLDER** :-1:
2018-10-25 11:58:42 +05:30
```shell
2018-11-19 15:12:07 +11:00
grep -ir "Query" file.txt
```
2019-11-12 13:47:46 +11:00
![grep ](./grep.jpg )
2018-11-19 15:12:07 +11:00
## view an image
**STOP USING PREVIEW** :-1:
```shell
imgcat image.png
2018-10-25 11:58:42 +05:30
```
2018-12-13 01:19:58 +11:00
## show disk size
**STOP RIGHT CLICKING DISK ICON OR OPENING DISK UTILITY** :-1:
```shell
df -h
```
2018-12-13 16:04:49 +11:00
## check performance of your computer
**STOP OPENING YOUR ACTIVITY MONITOR OR TASK MANAGER** :-1:
```shell
top
```
2018-11-14 11:20:28 +11:00
## Quick tips
![CLI tips ](./cli_tips.jpg )
2018-11-14 11:59:53 +11:00
## Hotkeys
```
2018-11-19 15:07:28 +11:00
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
2018-11-14 11:59:53 +11:00
Ctrl + L Clears the Screen, similar to the clear command
2018-11-19 15:07:28 +11:00
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’ s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W Delete the word before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor
Alt + F Move cursor forward one word on the current line
Alt + B Move cursor backward one word on the current line
Tab Auto-complete files and folder names
2018-11-14 11:59:53 +11:00
```
2017-04-26 09:33:46 +10:00
---
2016-09-18 18:16:37 +10:00
_Remember, you can always google or `man` the commands you are not familiar with._