1.11 - Linux Commands Flashcards

1
Q

Linux commands

A
  • The command line - Terminal, XTerm, or similar
  • Commands are similar in both Linux and macOS
    – Mac OS derived from
    BSD (Berkeley Software Distribution) Unix
    – This section is specific to Linux
  • Download a Live CD or install a virtual machine
    – Many pre-made Linux distributions are available
  • Use the man command for help - An online manual
    > man grep
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Bash - ls

A
  • List directory contents
    – Similar to the dir command in Windows
  • Lists files, directories
    – May support color coding;
    – Blue is a directory, red is an archive file, etc.
  • For long output, pipe through more:
    > ls -l | more
    (use q or Ctrl-c to exit)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Bash - pwd

A
  • Print Working Directory
    – Displays the current working directory path
    – Useful when changing directories often
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Bash - mv

A
  • Move a file or rename a file
  • mv SOURCE DEST
    > mv first.txt second.txt
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Bash - cp

A
  • Copy a file - Duplicate files or directories
  • cp SOURCE DEST
    > cp first.txt second.txt
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Bash - rm

A
  • Remove files or directories - Deletes the files
  • Does not remove directories by default
    – Directories must be empty to be removed or
    must be removed with -r
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Bash - chown

A
  • Change file owner and group - Modify file settings
  • sudo chown [OWNER:GROUP] file
    > sudo chown professor script.sh
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Bash - su / sudo

A
  • Some commands require elevated rights
  • sudo
    – Execute a command as the super user or user ID
    – Only that command executes as the super user
  • su
    – Become super user or change to a different user
    – You continue to be that user until you exit
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Bash - chmod

A
  • Change mode of a file system object
    – r=read, w=write, x=execute
    – Can also use octal notation
    – Set for the file owner (u), the group(g),
    others(o), or all(a)
  • chmod mode FILE
    > chmod 744 script.sh
  • chmod 744 first.txt
    – User; read, write, execute
    – Group; read only
    – Other; read only
  • chmod a-w first.txt
    – All users, no writing to first.txt
  • chmod u+x script.sh
    – The owner of script.sh can execute the file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Bash - apt-get

A
  • Advanced Packaging Tool
    – Handles the management of application packages
    – Applications and utilities
  • Install, update, remove
    > sudo apt-get install wireshark
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Bash - yum

A
  • Yellowdog Updater, Modified (yum) -
    Install, delete, update
  • Manages RPM packages
    – Red Hat Package Manager - RPM Package Manager
    – A Linux distribution will commonly use either
    yum or apt-get
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Bash - ip

A
  • Manage the network interfaces
    – Enable, disable, configure addresses,
    manage routes, ARP cache, etc.
  • ip address
    – View interface addresses
  • ip route
    – View the IP routing table
  • sudo ip address add 192.168.121.241/24 dev eth0
    – Configure the IP address of an interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Bash - df

A
  • Disk Free - View file systems and free space
  • df
    – View number of blocks
  • df -h
    – View human-readable sizes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Bash - grep

A
  • Find text in a file
    – Search through many files at a time
    grep PATTERN [FILE]
    > grep failed auth.log
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Bash - ps

A
  • View the current processes
    – And the process ID (PID)
    – Similar to the Windows Task Manager
  • View user processes
    ps
  • View all processes
    ps -e | more
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Bash - top

A
  • View CPU, RAM, and resource utilizations
    – The “Task Manager” for Linux
  • Process information
    – Easy to find the highly utilized applications
  • Summary of overall load
    – One, five, and fifteen minutes
  • Many different options
    – Check the man page for startup options and keys
17
Q

Bash - find

A
  • Find a file by name or extension
    – Search through any or all directories
  • Find files with a specific extension
    > find . -name “*.txt”
18
Q

Bash - dig

A
  • Lookup information from DNS servers
    – Canonical names, IP addresses, cache timers, etc.
  • dig (Domain Information Groper)
    – Detailed domain information
19
Q

Bash - cat

A
  • Concatenate - Link together in a series
  • Copy a file/files to the screen
    cat file1.txt file2.txt
  • Copy a file/files to another file
    cat file1.txt file2.txt > both.txt
20
Q

bash - nano

A
  • Full-screen text editor - Easy to edit
  • Included with many Linux distributions - Easy to install
  • Select, mark, copy/cut, and paste text
    – Similar features to graphical-based editors