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
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)
3
Q
grep
A
- Find text in a file
- Search through many files at a time
- grep PATTERN [FILE]
- > grep failed auth.log
4
Q
cd
A
- Change current directory
- Nearly identical to Windows command line
- Forward slashes instead of backward
- cd
- > cd /var/log
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
6
Q
pwd
A
- Print Working Directory
- Displays the current working directory path
- Useful when changing directories ofte
7
Q
passwd
A
- Change a user account password
- Yours or another
- passwd [username]
8
Q
mv
A
- Move a file
- Rename a file
- mv SOURCE DEST
- > mv first.txt second.txt
9
Q
cp
A
- Copy a file
- Duplicate files or directories
- cp SOURCE DEST
- > cp first.txt second.txt
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
11
Q
mkdir
A
- Make a directory
- Create a folder for file storage
- mkdir DIRECTORY
- > mkdir notes
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
13
Q
chown
A
- Change file owner and group
- Modify file settings
- sudo chown [OWNER:GROUP] file
- > sudo chown professor script.sh
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
15
Q
•ifconfig
A
• View or configure a network interface and
IP configuration
•ifconfig eth0