I can't eject a disc You want to use a CD or a DVD, but…
Basic Linux Commands
ls – List directory contents
- Lists files, directories
- For long output, pipe through more: > ls -l | more
(use q or Ctrl-c to exit)
grep – Find text in a file
- grep PATTERN [FILE]
- > grep failed auth.log
cd – Change current directory
- Nearly identical to Windows command line
- Forward slashes instead of backward
- cd <directory>
- > cd /var/log
shutdown – Shut the system down
- sudo shutdown 2
- Shuts down and turns off the computer in two minutes
- sudo shutdown -r 2
- Shuts down and reboots in two minutes
- Ctrl-C to cancel
pwd – Print Working Directory
- Displays the current working directory path
- Useful when changing directories often
passwd – Change a user account password
- passwd
mv – Move (rename) a file
- mv SOURCE DEST
- > mv first.txt second.txt
cp – Copy a file
- cp SOURCE DEST
- > cp first.txt second.txt
rm – Remove files or directories
- Does not remove directories by default
- Directories must be empty or must be removed with -r
mkdir – Make a directory
- mkdir DIRECTORY
- > mkdir notes
chmod – 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
chown – Change file owner and group
- sudo chown [OWNER:GROUP] file
- > sudo chown professor script.sh
iwconfig – View or change wireless network configuration
- Requires some knowledge of the wireless network
- iwconfig eth0 essid studio-wireless
ifconfig – View or configure a interface and IP configuration
- ifconfig eth0
ps – View the current processes
- Similar to the Windows Task Manager
- View user processes – ps
- View all processes – ps -e | more
su – Become super user
- You continue to be that user until you exit
sudo – Execute a command as the super user
- Only that command executes as the super user
apt-get – Advanced Packaging Tool
- Handles the management of application packages
- > sudo apt-get install wireshark
vi – Visual mode editor
- Full screen editing with copy, paste, and more
- vi FILE
- > vi script.sh
- Insert text – i <text>
- Exit insert mode with Esc
- Save (write) the file and quit vi – :wq
dd – Convert and copy a file
- Backup and restore an entire partition
- > dd if=<src file name> of=<target file name> [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