Chapter 15: Command Line Interface Flashcards
CLI
Command Line Interface
Shell
Command line interpreter program
\
backslash (Windows)
/
forward slash (UNIX)
sudo; su
Super user privileges in UNIX, write before your commands
Working Directory
Current directory (where terminal is focused)
Absolute Path
full file location
Relative Path
path based off a starting point
pwd
UNIX - full path
~
UNIX - home directory
switch
“options” for different commands, typically following the command
[command] /?
WINDOWS - get help on what command does (manual)
man [command]
UNIX - get help on what command does (manual)
builtin vs external
builtin - command that is part of the shell
external - command that is not innate to shell
type [command]
UNIX - gives the type of command written
type - a [command]
UNIX - gives all types of that command, not just default type
Get-[command]
WINDOWS - gives info on command
dir
dir /p
WINDOWS - shows directory contents
shows directory contents but pauses after one page
ls
ls | more
ls -l
UNIX - shows directory contents
shows contents but pasuses after one page
shows long form details on contents
cd \path
cd ..
changes directory focus
moves focus up a directory (to parent)
e: (command prompt)
WINDOWS - switches to e: drive
Switching drives in UNIX
must look manually
MacOS - check the /Volumes
Ubuntu - check /mnt or /media/<user></user>
md [name]
WINDOWS - create a directory given name
mkdir [name]
UNIX and WINDOWS - create a directory given name
rd [name]
WINDOWS - remove directory
rmdir [name]
UNIX AND WINDOWS - remove directory
rd [name] /s
WINDOWS - remove directory and all contents
rm -r [name]
UNIX - remove direcotry and alll contents
more [name]
WINDOWS - when in directory, writes out contents of txt file
cat [name]
WINDOWS AND UNIX - when in directory, writes out contents of txt file
wildcards
use * to indicate catchall spaces e.g. .pdf (all pdf files) or a (all files that start with “a”)
del [name]
WINDOWS - deletes a file
rm [name]
UNIX - deletes a file
copy [name]
WINDOWS - copies a file
syntax for copying/moving in WINDOWS or UNIX
[command] [name] [destination path]
move [name]
WINDOWS - moves a file
cp [name]
UNIX - copy a file
mv [name]
UNIX - move a file
xcopy
WINDOWS - copy bulk directories
xcopy switches
/s - copy all subdirectories that aren’t empty
/e - include all empty directories
robocopy
WINDOWS - Robust Copy, can copy across networks, has many functions
Robocopy syntax and mirror switch
robocopy [source path] [destination path] [options]
/mir - mirror source structure
format
WINDOWS - format a volume, has extensive switch options
hostname
WINDOWS - show name of computer
winver
WINDOWS - get version info
gpupdate
WINDOWS - update group policy (force)
gpresult
WINDOWS - detailed group policy
gpresult syntax
gpresult /user [username] /r
sfc
WINDOWS - system file check, fix corrupted files
shutdown
WINDOWS - turn off machine
/r to restart
ps aux
UNIX - onetime snapshot of current processes (detailed)
top
UNIX - focuses on resource hungry process
chkdsk /f /r
WINDOWS - scan, detect, and repair disk issues
/f - fix file errors
/r - locate and repair bad sectors
ps vs top
UNIX
ps gives you snapshot of processes and details on this info
top gives you dynamic, updating, interactive info on processes
grep
UNIX - search for and print text strings in a file (may need to specify path)
find syntax
UNIX:
find [path] -iname “criteria”
looks for files that match criteria
APT
UNIX - Advanced packaging tool, used to manipulate apps via command line in Debian family
apt-get update
UNIX - Updates Ubuntu systems
yum
UNIX - packaging tool used to manipulate apps via command lin in Redhat family
nano
UNIX - creates a text file
nano “file” for name
dd
UNIX - create an image of a drive
df -h
UNIX - what diskspace is free?
-h switch creates human friendly output
Scripting Languages
Batch File/.bat - old command, DOS
PowerShell/.ps1 - modern windows
bash/.sh - UNIX
Python/.py
Javascript/.js
VisualBasicScript/.vbs
Use Cases for Scripting
Basic Automation
Restarting Machines
Remapping Network Drives
Installing Apps
AutoBackup
Data Gathering
Updates