2016-09-17 18:54:40 +10:00
# You Don't Need GUI
< 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-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
2017-11-17 16:59:51 +11:00
**STOP DRAG AND DROP 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
2017-11-17 16:59:51 +11:00
**STOP RIGHT CLICK 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
2017-11-17 16:59:51 +11:00
**STOP DRAG AND DROP 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
2017-11-17 16:59:51 +11:00
**STOP RIGHT CLICK 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
2017-11-17 16:59:51 +11:00
**STOP DRAG AND DROP A FILE, OR CTRL + X, 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
2017-11-17 16:59:51 +11:00
**STOP RIGHT CLICK 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
2017-11-17 16:59:51 +11:00
**STOP DRAG AND DROP A FOLDER, OR CTRL + X, 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
2017-11-17 16:59:51 +11:00
**STOP RIGHT CLICK 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
2017-11-17 16:59:51 +11:00
**STOP DRAG AND DROP 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
2017-11-17 16:59:51 +11:00
**STOP RIGHT CLICK AND CREATE A NEW FILE** :-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
touch 'new file'
2017-06-07 14:48:44 +10:00
# or
2016-11-13 21:39:19 -02:00
> 'new file'
```
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
2017-11-17 16:59:51 +11:00
**STOP RIGHT CLICK 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
2017-11-17 16:59:51 +11:00
**STOP RIGHT CLICK 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
2017-11-17 16:59:51 +11:00
**STOP DOUBLE CLICKING 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
2017-11-17 16:59:51 +11:00
**STOP RIGHT CLICK 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
2017-11-17 16:59:51 +11:00
**STOP RIGHT CLICK 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
2017-11-17 16:59:51 +11:00
**STOP RIGHT CLICK 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
2017-11-17 16:59:51 +11:00
**STOP RIGHT CLICK 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
Want to use a calculator?
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-04-28 14:44:29 +09:30
**STOP FORCE QUIT A PROGRAM USING GUI** :-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
**CHECK THE RESPONSE OF A DOMAIN OR IP ADDRESS** :-1:
```shell
ping url_or_ip
Example : ping umair.surge.sh
```
2018-11-06 13:29:41 +05:30
## view content of a file
**VIEW THE CONTENT OF ANY FILE** :-1:
```shell
cat file_full_path
Example : cat apps/settings.py
```
2018-10-25 11:58:42 +05:30
## search for a text
**SEARCH FOR A PATTERN IN FILES** :-1:
```shell
grep [options] pattern [files]
Example : grep -ir "Query" file.txt
Options Description
-c : This prints only a count of the lines that match a pattern
-h : Display the matched lines, but do not display the filenames.
-i : Ignores, case for matching
-l : Displays list of a filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not matches the pattern
-e exp : Specifies expression with this option. Can use multiple times.
-f file : Takes patterns from file, one per line.
-E : Treats pattern as an extended regular expression (ERE)
-w : Match whole word
-o : Print only the matched parts of a matching line, with each such part on a separate output line.
-r : Search repetitively/iteratively
```
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._