Linux Admin Basics Flashcards
List fundamental commands for admins that install and integrate applications in Linux
Handling files
- Create [file/directory]
- Copy [file/directory]
- Copy to a remote system
- Move/Cut&Paste [file/directory]
- Delete [file/directory]
- Close [file]
- a. cat [myfile.txt] or touch [myfile.txt]
b. mkdir [directory] - a. cp [source file] [destination file&directory]
b. cp -r [source directory] [destination directory] - scp OR sftp
- a. mv [source file] [destination]
- a. rm [myfile.txt]
b. rm -r dir [directory] OR rmdir (removes empty directory) - q
Command line
- View all including hidden directory contents
- Browse directories
a. current directory
b. parent directory - View current directory
- ls -la
- cd
a. .
b. .. - pwd
Searching
- Search for file or directory
- Search for a string in a file
- Go up a page within file
- Go down a page within a file
- find [file or directory] OR locate [file or directory]
- grep -i [keyword]
- ctrl + b
- space bar
Show
- Show file
- Show last 10 lines of file
- Show text output of e.g. env. variable
- Show processes
- Show all previously run commands
- Show disk usage
- cat [file.txt]
- tail [file.txt]
- Echo [env. var]
- a.ps -e (shows all processes) OR top
b. ps - u [username] (shows processes of named user) - history
- du -k or du -h
Compressing and Archiving
- Create a collection of files and directories in one file> archiving
- Reduce/compress file size
- Uncompress
- a. tar - c [file] (archives file> file.tar)
b. tar - x [file] (unarchives a file) - gzip [file] (creates> file.gzip)
tar -z [file]
tar -cz (archives&zips file creating> file.tgz) - gunzip [file.gz]
tar -zxf file.tar.gz
Install / Uninstall
- Install packages in RPM
- Delete packages in RPM
- a Find available packages
- List installed packages
- Install packages in Debian
- Remove packages in Debian
- yum install [package in directory]
- yum remove [package in directory]
- a yum search [name of package]
- rpm -qa
- a. apt install [package in directory]
b. dpkg [package] (installs local package) - apt remove (package in directory)
Moving files to remote systems
- Transfer files
- Transfer files and view remote directories
- Graphical clients
- pscp [options] [user@]host:source target
a. Putty secure client scp
b. Download PSCP.EXE from Putty download page.
c. Open command prompt and type set PATH=
d. In command prompt point to the location of the pscp.exe using cd command.
e. Type pscp.
f. Use the following command to copy file form remote server to the local system
pscp [options] [user@]host:source target. - Use secure ftp:
a. sftp [remote-system IP] (login to remote syste)
b. cd [target-directory] (change to remote directory)
c. ls -l (confirm you have read permissions for file)
d. get [filename] (copy file)
e. bye (end connection) - a. WinSCP
b. FileZilla
d. Cyberduck
Environment Variables
- Show all env var
- Show where a particular env. var is located
- Set env. var
- Remove an env var
- Make env var. persist after startup
- printenv
- echo $[env var]
- a. cd [directory of env var]
b. [env var]=[target env path] - unset [env var]
- Go to one of the three locations and edit the file:
/etc/environment»_space;> JAVA_PATH=/usr/local/java
/etc/.bashrc»_space;> export PATH=”$JAVA_PATH:$PATH”
~/.pam_environment»_space;>PATH DEFAULT=/usr/bin:usr/local/bin
Linux Directory
/bin /sbin /etc /home /opt /tmp /usr /var /cdrom /mnt /proc
** potential logs for third party software
/bin – executable files aka essential binaries
/sbin – system binaries
/etc ** – host specific system config
/home – home directories
/opt ** – config file for third party application software
>bin
>etc
>lib
>log
/tmp – temporary files deleted on boot
/usr ** – sharable and read only files
>bin
>etc
>lib
>log
/var ** – var. data files generated by system or vendor
/cdrom – mount point for CDs
/mnt – mount point f external file systems
/proc – running processes
Attach a folder/directory to a home directory
Remove the attached directory
> mount [mountable folder] [destination directory]
> umount [mounted folder]