JustToThePoint English Website Version
JustToThePoint en español
JustToThePoint in Thai

How to use the terminal like a pro

The command line is the ultimate power tool on your computer. Using it can feel a bit intimidating, overwhelming and complex, but it allows you tonavigate through files and folders, create, copy, move and delete files and directories, execute commands with multiple options, install and run programs, etc.

You can be more productive using a terminal than a GUI, and you can easily automate tasks, such as creating, copying, and converting files, backing up files or folders to a portable hard drive, cleaning up your system, installing multiple programs at once, etc.  

Open your terminal

  1. Windows: Open the start menu and type in terminal, cmd or PowerShell. Alternatively, press Windows and R, then type cmd or PowerShell in the Run window.
  2. macOS: Open spotlight search by hitting command and the space bar and type in terminal. If you are going to use the Terminal very often, you should add it to the Dock. Right click on the terminal icon, choose Options, Keep To Dock.
  3. GNU/Linux: Use the keyboard shortcut Ctrl + Alt + T. Besides, you can open a terminal from the Activities menu in GNOME. Simply type terminal and click on the result that pops up.

Basic commands

  1. Windows: move myFile.doc c:\myDirectory; move myDirectoryTarget myDirectoryDestination
  2. macOS/Linux: mv myFile.txt myDirectory; mv myDirectoryTarget myDirectoryDestination
  1. Windows: copy myFile.doc c:\myDirectory; copy *.txt c:\myDirectory -it copies all the txt files in the current directory to c:\myDirectory-; xcopy myDirectoryTarget myDirectoryDestination /e -this command copies all files and folders recursively even empty directories-.
  2. macOS/Linux: cp myFile.doc myDirectory; cp *.txt myDirectory; cp -r myDirectoryTarget myDirectoryDestination -copying a directory is the same as copying a file, but you need to use the recursive -r option.
  1. Windows: del myFile.txt; del *.txt; rmdir myDirectory /s. /s deletes a directory tree (the specified directory -myDirectory- and all its subdirectories, including all files).
  2. macOS/Linux: rm myFile.txt; rm *.txt; rm -r myDirectory. rm -r removes directories and their contents recursively.
  1. Windows: dir (lists all files and directories contained in the current directory), tree (displays the directory structure).
  2. macOS/Linux: ls, ls -a (list hidden files, i.e., do not ignore entries starting with .)

Windows commands

  1. ipconfig /all, it displays the full TCP/IP configuration for all adapters; ipconfig /flushdns, it flushes and resets the contents of the DNS client resolver cache; ipconfig /release followed by ipconfig /renew forces your Windows into asking for a new IP address.
  2. netstat -an helps you identify currently open ports and related IP addresses.
  3. ping myWebDomain/myIPAdress checks if a web domain or IP address is accessible or not.
  4. tracert myWebDomain.com/myIPAdress shows the number of steps or hops between your PC and the target, along with how much time each hop takes.
start c:\MyFiles\MyDocument.doc # Opens the file MyDocument.doc in Word or WordPad. 
start https://www.justothepoint.com # Opens JustToThePoint in your default browser.

macOS/Linux commands

  1. ifconfig -a or ip a displays information for all network interfaces. To enable/disable a network interface, type ifconfig eth0 up/down To assign an IP Address to a network interface, write: ifconfig eth0 192.168.0.7
  2. netstats or ss | less gives you information about your network connections, the ports that are in use, and the processes using them.
  3. ping myWebDomain/myIPAdress checks if a web domain or IP address is accessible or not.
  4. traceroute myIPAddress/myWebPage prints the route packets take to reach the destination specified by the user. It displays each network hop and the time taken to reach it. To install it, use the following command: sudo pacman -Sy traceroute (Arch), sudo apt-get install traceroute (Ubuntu).
  1. View all mounted disks and partitions (df -h) and unmount the disk: unmount /dev/sdb (/dev/sda is the first hard drive; /dev/sdb is the second drive, etc.)
  2. Repair errors automatically with fsck: fsck -y /dev/sdb
  3. Run fsck on Linux Root Partition: Reboot (sudo reboot); Press and hold the shift key during boot-up so that the grub menu is shown. Select the Advanced options, then Recovery mode, fsck. You will be asked the following question, Continuing will remount your / filesystem in read/write mode and mount any other filesystem defined in /etc/fstab? Do you wish to continue? Confirm by selecting Yes. Finally, select resume to boot up your machine.
  1. macOS: diskutil list lists all disks and their partitions. system_profiler reports on the hardware and software configuration of your macOS system. sw_vers prints your macOS operating system version information.
  2. GNU/Linux: The lshw is a nifty command-line tool to extract detailed information on the hardware configuration of your system (sudo apt-get install lshw). lsblk lists out all the storage blocks you have on your system, which includes hard drive partitions, flash drives, and optical drives. uname is a command-line utility that prints basic information about the operating system and system hardware: uname -a

Other commands for macOS and GNU/Linux

You can change Neofetch’s config file (nvim .config/neofetch/config.conf) to customize it and display exactly what you want it to.

We are going to add our favorite quotes. The format needs to be as follows:
You cannot achieve the impossible without attempting the absurd.
%
\

nvim .zsh_aliases: alias fortune=’fortune ~/.config/myquotes/fortunes'

mkdir myquotes && cd myquotes
wget https://github.com/ruanyf/fortunes/blob/master/data/fortunes
strfile fortunes #  strfile creates a random access file for storing strings
    user@pc:~$ bc
    bc 1.07.1
    Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'.
    2*4
    8
    ((7+5)/2)^2
    36
    (3^2)*(9)/3
    27
    user@pc:~$ user@pc:~$ defaults write com.apple.finder AppleShowAllFiles -bool true # It shows hidden files and folders.
    user@pc:~$ user@pc:~$ defaults write com.apple.finder AppleShowAllFiles -bool false # It disables the display of hidden files and folders.
    defaults write com.apple.screencapture location ~/Dropbox # It changes the default location for screenshots.
    defaults write com.apple.screencapture type JPG # It changes the default file type of screenshots.
    defaults write com.apple.screencapture disable-shadow -bool true # It disables shadows for all window screenshots captured on your macOS.
    killall SystemUIServer
open -a gimp #  Opens Gimp, the GNU Image Manipulation Program. 
open https://justothepoint.com # Opens an URL with the default browser.
git clone https://github.com/hkbakke/bash-insulter.git bash-insulter # First, clone the repository
sudo cp bash-insulter/src/bash.command-not-found /etc/ # The script is quite simple, do not worry about it.

vim .zshrc (Zsh) or vim etc/bash.bashrc (Bash)
if [ -f /etc/bash.command-not-found ]; then
    . /etc/bash.command-not-found
fi

echo 'Defaults insults' >> /etc/sudoers # Sudo insults you if you enter an incorrect password. 
Bitcoin donation

JustToThePoint Copyright © 2011 - 2024 Anawim. ALL RIGHTS RESERVED. Bilingual e-books, articles, and videos to help your child and your entire family succeed, develop a healthy lifestyle, and have a lot of fun. Social Issues, Join us.

This website uses cookies to improve your navigation experience.
By continuing, you are consenting to our use of cookies, in accordance with our Cookies Policy and Website Terms and Conditions of use.