5.7 KiB
You Don't Need GUI
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).
However, they often require more resources, are less powerful and hard to automate via scripting.
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.
Quick links
- copy a file
- duplicate a file
- copy a folder
- duplicate a folder
- move a file
- rename a file
- move a folder
- rename a folder
- merge folders
- create a new file
- create a new folder
- show file/folder size
- open a file with the default program
- zip a folder
- unzip a folder
- remove a file
- remove a folder
- list folder contents
- tree view a folder and its subfolders
- find a stale file
- show a calendar
- find a future date
- use a calculator
- kill a program
copy a file
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/
duplicate a file
STOP RIGHT CLICK AND DUPLICATE A FILE 👎
cp readme.txt readme.bak.txt
copy a folder
STOP DRAG AND DROP A FOLDER, OR CMD/CTRL + C, CMD/CTRL + V A FOLDER 👎
Copy myMusic
folder to the myMedia
folder
cp -a myMusic myMedia/
# or
cp -a myMusic/ myMedia/myMusic/
duplicate a folder
STOP RIGHT CLICK AND DUPLICATE A FOLDER 👎
cp -a myMusic/ myMedia/
# or if `myMedia` folder doesn't exist
cp -a myMusic myMedia/
move a file
STOP DRAG AND DROP A FILE, OR CTRL + X, CTRL + V A FILE 👎
mv readme.txt documents/
Always use a trailing slash when moving files, for this reason.
rename a file
STOP RIGHT CLICK AND RENAME A FILE 👎
mv readme.txt README.md
move a folder
STOP DRAG AND DROP A FOLDER, OR CTRL + X, CTRL + V A FOLDER 👎
mv myMedia myMusic/
# or
mv myMedia/ myMusic/myMedia
rename a folder
STOP RIGHT CLICK AND RENAME A FOLDER 👎
mv myMedia/ myMusic/
merge folders
STOP DRAG AND DROP TO MERGE FOLDERS 👎
rsync -a /images/ /images2/
create a new file
STOP RIGHT CLICK AND CREATE A NEW FILE 👎
touch 'new file'
# or
> 'new file'
create a new folder
STOP RIGHT CLICK AND CREATE A NEW FOLDER 👎
mkdir 'untitled folder'
# or
mkdir -p 'path/may/not/exist/untitled folder'
show file/folder size
STOP RIGHT CLICK AND SHOW FILE/FOLDER INFO 👎
stat -x readme.md
# or
du -sh readme.md
open a file with the default program
STOP DOUBLE CLICKING A FILE 👎
xdg-open file # on Linux
open file # on MacOS
zip a folder
STOP RIGHT CLICK AND COMPRESS FOLDER 👎
zip -r archive_name.zip folder_to_compress
unzip a folder
STOP RIGHT CLICK AND UNCOMPRESS FOLDER 👎
unzip archive_name.zip
remove a file
STOP RIGHT CLICK AND DELETE A FILE PERMANENTLY 👎
rm my_useless_file
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.
remove a folder
STOP RIGHT CLICK AND DELETE A FOLDER PERMANENTLY 👎
rm -r my_useless_folder
list folder contents
STOP OPENING YOUR FINDER OR FILE EXPLORER 👎
ls -la my_folder
tree view a folder and its subfolders
STOP OPENING YOUR FINDER OR FILE EXPLORER 👎
tree # on Linux
find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' # on MacOS
find a stale file
STOP USING YOUR FILE EXPLORER TO FIND A FILE 👎
Find all files modified more than 5 days ago
find my_folder -mtime +5
show a calendar
STOP LOOKING UP WHAT THIS MONTH LOOKS LIKE BY CALENDAR WIDGETS 👎
Display a text calendar
cal
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?
date -d "+7 days" # on Linux
date -j -v+7d # on MacOS
use a calculator
STOP USING CALCULATOR WIDGET 👎
Want to use a calculator?
bc
force quit a program
STOP FORCE QUITE A PROGRAM USING GUI 👎
killall program_name
Remember, you can always google or man
the commands you are not familiar with.