Basic Linux Commands Flashcards

1
Q

Linux commands

A

• The command line - Terminal, XTerm, or similar

• Commands are similar in both Linux and Mac OS
• 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
    • I’m using Ubuntu in a virtual machine
  • 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

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

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
4
Q

cd

A
  • Change current directory
    • Nearly identical to Windows command line
    • Forward slashes instead of backward
  • cd
    • > cd /var/log
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

shutdown

A
  • Shut the system down
    • Safely turn off the computer in software
    • Similar to the Windows shutdown command

•sudo shutdown 2
• Shuts down and turns off the computer
in two minutes

  • sudo shutdown -r 2
    • Shuts down and reboots in two minutes
    • Important when you’re not on site

•Ctrl-C to cancel

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

pwd

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

passwd

A
  • Change a user account password
  • Yours or another
  • passwd [username]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

mv

A
  • Move a file
    • 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
9
Q

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
10
Q

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
11
Q

mkdir

A
  • Make a directory
    • Create a folder for file storage
  • mkdir DIRECTORY
    • > mkdir notes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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
13
Q

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
14
Q

•iwconfig

A
  • View or change wireless network configuration
  • essid, frequency/channel, mode, rate, etc.
  • Requires some knowledge of the wireless network
  • iwconfig eth0 essid studio-wireless
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

•ifconfig

A

• View or configure a network interface and
IP configuration
•ifconfig eth0

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

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
17
Q

su / sudo

A
  • Some command require elevated rights

* There are some things normal users can’t do

18
Q

•su

A
  • Become super user
  • Or change to a different user
  • You continue to be that user until you exit
19
Q

•sudo

A
  • Execute a command as the super user
  • Or as a different user ID
  • Only that command executes as the super user
20
Q

apt-get

A
  • Advanced Packaging Tool
    • Handles the management of application packages
    • Applications and utilities
  • Install, update, remove
    • > sudo apt-get install wireshark
21
Q

vi

A
  • Visual mode editor
    • Full screen editing with copy, paste, and more
  • vi FILE
    • > vi script.sh
22
Q

• Insert tex

A
  • i
  • Exit insert mode with Esc
  • Save (write) the file and quit vi
  • :wq
23
Q

dd

A
  • Convert and copy a file
  • Backup and restore an entire partition
  • > dd if= of=
[Options]
• Creating a disk image
•> dd if=/dev/sda of=/tmp/sda-image.img
• Restoring from an image
•> dd if=/tmp/sda-image.img of=/dev/sda
24
Q

Closing programs

A

• Use terminal - sudo for proper permissions

  • killall
  • sudo killall firefox
  • xkill
  • Graphical kill

•kill

25
Q

A user calls the helpdesk wanting a simple method he can use for backing up multiple large directories on a Linux system. What command allows users to back up and compress large directories?

A

tar