1) Command Line Flashcards

1
Q

Windows: Dir

A

Displays contents of current working directory.

Switches:
/p = Pauses after screen full of info
/w = Displays only filenames
/a = Displays files with specified attributes (see below)
D = Directories | H = Hidden files | R = Read-only
S = System files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Windows: Cd

A

Changes to specified directory (change directory)
Syntax: cd \documents\testfolder
Change Drives: cd D (do not use colon, just drive letter)
.. = Move up a directory
\ = root directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Windows: Md/Rd

A

Md = Make Directory
Syntax: md /documents/newfolder

Rd = Remove directory
Syntax: rd /documents/newfolder

Rd Switches
/S = Removes all directories & files in specified directory
/Q = Quiet mode, does not ask if okay to remove

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Windows: Ipconfig

A

Displays IP configuration details

Switches
/all = Displays all IP config info
/release = releases current IP address from DHCP
/renew = re-assigns an IP via DHCP
/flushdns = clears DNS cache
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Windows: Ping

A

Used to test if an domain/IP can be reached & how long it takes

Switches

  • t = ping specified host until stopped (ctrl-c)
  • a = resolve address to host names
  • l = specify ping packet size (buffer size)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Windows: Tracert

A

Shows the route that a packet takes to get to its destination (via domain or IP address)

Switches

  • d = do not resolve addresses to hostnames
  • 4 = force using IPv4
  • 6 = force using IPv6
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Windows: Netstat

A

Shows all TCP/UDP connections on your computer

Switches

  • a = displays all connections & listening ports
  • q = displays all connections, listening ports, and bound non-listening TCP ports
  • r = displays routing table

Dion recommends -ano switch to view details

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Windows: Nslookup

A

Enables you to determine exactly what info the DNS server is giving you about a specific hostname.
Displays host’s IP address (4 & 6)

Takes you to its own terminal
Then type in the web address being queried

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Windows: Shutdown

A

Enables you to shut down a local or remote computer

Switches
/r = reboot (full shutdown/restart)
/s = shutdown
/l = log off
/a = abort shutdown
/m \\computer = specify target computer
/f = force applications to close without warning
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Windows: Sfc

A

System file checker
Looks at system store (backup copies of critical files)
Compares them with current working files
Can choose to repair or verify only

Switches
/scannow = scans integrity of all protected files & repairs if needed
/verifyonly = scans integrity of all protected files
no repairs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Windows: Dism

A

Deployment Image Servicing/Management Tool
Best to run sfc first, if sfc finds a problem, run dism

Syntax: dism /online /cleanup-image /restorehealth
dism /online /cleanup-image /checkhealth

Enumerates, installs, uninstalls, configures, & updates features/packages in Windows images.

Switches
/online = Targets running OS
/checkhealth = looks for corruptions inside image
/restorehealth = attempts to repair corrupted scanned files automatically

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Windows: Chkdsk

A

Checks a HDD & displays a status report

Switches
/f = fixes errors on the disk

Volume = specify drive to check
Syntax: chkdsk volume:C:

/scan = runs online scan of volume
/L:size = specify log file size in Kb
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Windows: Diskpart

A

Type ? for help
Command line partitioning tool equipped with its own commands.

List disk (shows disks & disk numbers)
Select disk 1 (select disk number 1 or whichever)
Create partition primary
List partition
Select partition
Assign (assigns drive letter to selected drive/partition)
Clean (removes all partition/volume formatting)
Create (creates partition on a disk)

Format (formats drive)
Syntax: format fs=ntfs quick label=test
Quick formats to NTFS with name test

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Windows: Tasklist/Taskkill

A

Tasklist
Displays current running programs with PIDs & mem usage

Taskkill
Kills process by PID or name

Switches
/f = force quit
/t = terminates the process & child processes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Windows: Gpupdate

A

Forces an update to new group policies (AD)

Switches
/force = reapplies policy settings
/target = specify user/computer to target update for
/logoff = logoff after GP updates
/boot = restart after applying GP updates

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Windows: Gpresult

A

Gives a quick overview of all security policies applied to a user/computer

Switches
/s = specifies name/IP of a remote PC (default: local)
/u = uses credentials of specified user to run command
/p = specifies password of user provided by /u
/z = displays all info about GP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Windows: Format

A

Formats a disk to accept Windows files (admin)
Syntax: format e: /q /fs:exFAT

Switches
/q = quick format
/c = compress new volume (NTFS)
/fs: = specify file system
/v: = specify volume name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Windows: Copy/Move/Del

A

Copy = copy file
copy filename.txt \users\filepath

Move = moves file (same copy syntax)

Del = deletes file
del \documents\file.txt
Wild card = *
del *.txt (deletes all text files)
del *.* (deletes all files in directory)
19
Q

Windows: Xcopy

A

Copies files & directories, including subdirectories

Switches
/s = copy all subdirectories
/h = copy hidden files
/l = list files to be copied
/r = copies read-only files
20
Q

Windows: Robocopy

A

Basically the same as Xcopy except:
Checks destination directory & doesn’t waste time copying unchanged files

Switches
/s = copies subdirectories (excludes empty)
/e = copies subdirectories (includes empty)
/mov = files, delete from source after copied (cut)
/move = files/directories, delete from source after (cut)

21
Q

Windows: Net use

A

Used for mapping network shares

Syntax Example: Map resource to x: drive
net use x: \server1\research

22
Q

Windows: Net user

A

Create/delete/change user accounts (admin)

On its own, displays user list

Syntax: net user username password
net user JohnDoe password123 /add
net user JohnDoe /delete

/active:no/yes = enables/disables user account

23
Q

Windows: /?

A

Shows help options for specified command.

24
Q

Linux: Ls

A

Displays contents of present working directory.
/ = Root directory | .. = Parent directory
~ = Home directory

ls > output.txt (outputs result to file)

Flags

  • l = long format info
  • la = includes hidden files/directories
  • lh = displays file size too
  • s = shows folder/file size
  • t = sort by last modified date/time (-tr to reverse)
  • R = all files/directories with subdirectories
  • S = sort by file size (Sr to reverse)
25
Linux: Pipe "|"
Lets you use 2+ commands such that the output of one command serves as the input to the next Cat filename | less Displays file contents with one scroll length at a time
26
Linux: Grep
Used to search for a string of characters in a specified file. Syntax: grep "string" filename.txt With pipeline ifconfig | grep 192.168.4.15 Flags - r = recursive search (all files/subdirectories) - l = list files containing the match - w = whole word matches - n = line number - i = removes case sensitivity
27
Linux: Cd
Changes directory Syntax: cd Documents or cd /home/user/Documents Add quotes if there is a space in the folder name
28
Linux: Cat
Displays file contents Syntax: cat flags filename cat list1.txt Flags - A = show all - n = adds line numbers
29
Linux: Shutdown
Shuts down computer ``` Flags -c = cancel shutdown +20 = specifies number of minutes until shutdown 15:00 = specifies time to shut down Now = shutdown immediately ``` -r = reboot system (1 min) or add "now" or specific time to schedule restart
30
Linux: Pwd
Shows present working directory.
31
Linux: Passwd
Change user password Syntax: passwd username Will have you enter current password and new password. Flags - e = set an account's password to expire - l = lock user account - d = delete password
32
Linux: Mv
Move file to specified path Syntax: mv flags source destination mv file1.txt file2.txt = basically renames file mv file1.txt dir1/ = moves file to dir1 directory Flags - i = will prompt if you are overwriting - v = (verbose) displays what is happening
33
Linux: Cp
Copies file to specified path Syntax: cp flags source destination Source can be 1+ files - i = will prompt if overwriting - R = recursive copy (creates directory specified if it doesn't exist)
34
Linux: Rm/Rmdir
Rmdir = remove directory Syntax: rmdir flags directoryname -p = removes all directories in filepath -v = (verbose) displays what is happening Rm = remove files & directories - r = removes directory structure - f = never prompt user (ignores nonexistent files) - d = identical to rmdir
35
Linux: Mkdir
``` Make directory (creates directory) Syntax: mkdir directoryname mkdir directory/pictures = creates subdirectory ``` Create multiple directories mkdir -p folder/{sub1,sub2,sub3} -p = creates directory structure
36
Linux: Chmod
Changes file permissions for specified file chmod u+x file.txt = adds x for owner chmod u-x file.txt = removes x for owner Numbering 4 = r | 2 = w | 1 = x 7 = rwx | 6 = rw | 5 = rx chmod 754 file.txt rwx for owner | rx for group | r for other This is over-simplified for someone that doesn't fully understand
37
Linux: Chown/Chgrp
Chown = change file owner sudo chown devon file.txt -R = apply to files within directories recursively Chgrp = change group owner Old, you can do this with chown
38
Linux: iwconfig/ifconfig
ifconfig = basically ipconfig for Linux/macOS iwconfig = gives details about NIC(s)
39
Linux: Ps
Displays processes currently running (PID & name) Flags aux = list all details for all processes (all users) a = all users u = detailed process info x = list processes without a controlling terminal -r = all running processes -x = processes owned by user
40
Linux: Kill
Kills specified process (PID or name) Syntax: kill flags pid/processname kill 3286 or kill process-name Flags - KILL = force quit - 9 = sync kill, powerful force quit
41
Linux: su/sudo
Sudo Runs command with super-user/admin permissions -s = changes full terminal to root permissions Su Allows you to become another user Syntax: su user
42
Linux: Apt/Apt-get
``` Use sudo before running Apt update = update package lists Apt upgrade = install updated packages Apt install program-name Apt remove program-name Apt show package-name (package details) Apt search userquery (search for packages with query) ``` Apt-get is basically the same thing, except outdated
43
Linux: Vi
Built-in text editor for all Linux distros Syntax: vi filename.php If no extension is specified, txt file ``` Two Modes Command Mode (use cursor to select/cut/copy/paste/delete) ``` ``` Insert Mode (ESC key in command mode or press I) Insert & edit text ```
44
Linux: DD
Used to create an exact, bit-by-bit image of any form of block storage (any mass storage medium) Syntax: dd if= of= Uses: Copy a hard drive, backup a thumb drive, wipe a disk Wiping a disk dd if=/dev/urandom of=/dev/sdb