Basic Linux Commands Flashcards
Linux Commands
- The Command Line
- Terminal , xTerm , or similar
- Commands are similar in both Linux & Mac OS
- Mac derived from BSD (Berkley Software Distro) Unix
- Use the “man” command for help
- An online manual
- > man grep
SU / SUDO
-Some commands required elevated rights
- su
- Becomes super user
- Or change to a different user
- You continue as that user till you “exit”
- sudo
- Execute a command as the super user
- Or as a different user id
- Only that commands execute as a super user
Is
- List directory contents
- Similar to the ‘dir’ command in Windows
- List files , directories
- May support color coding
-For long output pipe through more
Is-1 | more (by page) use 9 or ctrl-c to exit
grep
- Find a text in a file
- Search through many files at a time
-grep PATTERN [file]
>grep failed auth.log
cd
- Change current directory
- Nearly identical to Windows Command Line
- Forward slashes instead of backwards
-cd
>cd/var/log
shutdown
- Shut the system down
- Safely turn off the computer in software
- Similar to the Windows shutdown command
- sudo shutdown 2
- shuts down & turn off the computer in 2min
- sudo shutdown - r2
- shuts down & reboots in 2min
-ctrl-c to cancel
pwd vs passwd
- pwd
- Print Working Directory
- Display the current working directory path
- Useful when changing directories often
- passwd
- Change a user account password
- Yours or another
mv
- Move a file
- Rename a file
-mv SOURCE DEST
>mv first.txt second.txt
cp
- Copy a file
- Duplicate files or directories
-cp SOURCE DEST
>cp first.txt. second.txt
rm
- Remove files or directories
- Deletes the files
-Does not remove directories by default
-Directories must be empty to be removed with
“rmdir” or must be removed with “rm-r”
mkdir
- Make a directory
- Create a folder for file storage
-mkdir Directories
>mkdir notes
chmod
1
- 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
2
- chmod 744 first.txt
- User ; read , write , execute
- Group ; read only
- Other ; read only
- chmod a-w first.all
- all users , no writing to first.txt
- chmod u+x script.sh
- The owner of script.sh can execute the file
chown
- Change file owner & group
- Modify file settings
-sudo chown [OWNER : GROUP] file
iwconfig / ifconfig
- iwconfig
- View or change wireless network configurations
- ESSID , frequency / channel , mode , rate , etc
- Requires knowledge of the wireless network
- iwconfig eth0 Essie studio-wireless
- ifconfig
- View or configure a network interface & IP configuration
- ifconfig eth0
ps
- View the current process
- And the process ID (PID)
- Similar to Windows Task Manager
- View user processor
- ps
- View all process
- ps-e | more
apt-get
- Application Packaging Tool
- Handles the management of application packages
- Applications & Utilities
-Install , update , remove
>sudo apt-get install wireshark
vi
- Visual mode editor
- Full screen editing with copy , paste , & more
-vi File
>vi script.sh
- Insert text
- I
- Exit insert mode with Esc
-Save (write) the file & quit = :wq
dd
- Convert & copy files
- Backup & restore an entire partition
-dd if = of = [Options]
- Creating a disk image
- > dd if = / dev / sea of = / tmp / sea-image.img
-Restoring from an image
>dd if = / tmp / sda -image.img of = / dev / sda