File Commands Cont.cp file1 file2 - used to copy the contents of one file into another file mv - used to rename files and directories cat filename - it allows us to create, view and concatenate files head filename- prints the first 10 lines of a file tail filename - prints the last 10 lines of a file sort - will sort the contents of a text file line by line more/less - two similar commands that both show info a page at a time, less is faster more allows user to scroll Systems Relatedsystemctl cat - views the content of a unit file systemctl status - shows the status of a system Systemctl list-units --type=service --state=running - will list active services Sudo systemctl start - this will start the service Sudo systemctl stop - this will stop the service Sudo systemctl reload- reloads the unit files for the service FILE COMPRESSIONtar xzf file.tar.gz - Extracts a tar using Gzip To Downlaod a Filewget file non-interactive network downloader which is used to download files from the server even when the user has not logged on to the system and it can work in the background without hindering the current process Misc SSH Commandsssh-keygen - creates a key pair for public key authentication ssh-copy-id - configures a public key as authorized on a server ssh-agent - agent to hold private key for single sign-on ssh-add - tool to add a key to the agent scp - file transfer client with RCP-like command interface sftp - file transfer client with FTP-like command interface sshd - OpenSSH server File Commandsls - lists the content of a directory cd - command is used to change directories pwd - displays the present working directory you are currently in mkdir - will create a new directory so long as it does not already exist rm filename - used to delete a file rm -r dir - used to delete a directory recursively along with its contents Other ls commands-a -lists all files even hidden -R -Recursively list subdirectories encountered -r - lists reverse order -S - sorts list by file size -t - sorts by last modified -1 - lists one file per line -l - lists in long listing format SSHSSH -Secure Shell or Secure Socket Shell, is a network protocol that gives users, particularly system administrators, a secure way to access a computer over an unsecured network ssh user@host connects the user to host Variablesenv Show environment variables echo $NAME Output value of $NAME variable export NAME=value Set $NAME to value $PATH Executable search path $HOME Home directory $SHELL Current shell |
Kernel Informationuname - When the uname command is used the kernel name is returned. uname -r- The uname -r command will display the release number of the kernel uname -v - The uname -v will display the version number of the kernel Notable Directories/bin - Holds essential Unix commands /sbin- holds commands for superuser, useful for system administration /boot- Location where the kernel and other boot files are stored /etc -files used by subsystems, ie. networking and mail, usually network services or disks to mount on /dev - Contains device files for the interface between the file system and hardware /proc - the interface between the filesystem and running processes Disk and System Infodu-this command is used to track the files and directories which are consuming space on the hard disk drive free - Displays the total amount of free space available on the system df - Displays information related to file systems about total space and available space lsblk - Lists information about all of the specified block devices cat/proc/cpuinfo - This is a short read-only text file that contains information about the CPUs Network Toolsifconfig <interface> <address> [up] : start the interface ifconfig <interface> [down|delete] : stop the interface netstat –w [seconds] –I [interface] : display network settings and statistics udpmt –p [port] –s [bytes] target_host : it creates UDP traffic udptarget –p [port] : it’s able to receive UDP traffic tcpmt –p [port] –s [bytes] target_host: it creates TCP traffic tcptarget –p [port]** it’s able to receive TCP traffic Search Commandsgrep pattern file - searches for a pattern in files Grep -r - will search recusively -v - performs inverted search - i - performs insensitive search -o - shows a matched part of the file\ find /dir/ -name " "* - finds files with " " in directory find /dir/-user " " -finds files owned by " " in directory whereis " " - will find binary source locate " " - finds file searched by a system index Shortcuts Continued!abc Run last command starting with abc !abc:p Print last command starting with abc !$ Last argument of previous command ALT-. Last argument of previous command !* All arguments of previous command |
Working with Usersuseradd -used to create a new user passwd - used to set a password for a new user userdel - to remove a user whoami- this will show the user information su "user" passwd - allows the user to change their password Package Managementdnf check-update - this will show a list of packages that are available but it will not perform any updates dnf upgrade- update the system and all of its packages dnf search “software”- to search for new software dnf install “software”- installs new software packages dnf remove - to remove a package from the system Alias CommandAlias - The command allows you to define your own commands or command shortcuts File permissionschmod octal file - Changes the permissions of file to octal, this can be found seperately for user, group, and world. 4- read (r) 2- write (w) 1- execute (x) chmod 777 - allows all users to read, write and execute chmod 755 - example, lets owner read write and execute while the group and the world can read and execute Help And Useful ShortcutsMAN PAGES man "command" - a user manual the is built into the terminal shows configuration files, system calls, library routines. ctrl c-stop current command ctrl z - stop the current command, resume with fg in the foreground or bg in the background ctrl d - log out of current session ctrl w - will erase one word on the line ctrl u - erases whole line ctrl r - brings up a recent command !! - repeat last cmd exit - log out of session Networkingifconfig -a - Displays network interfaces and ip address ifconfig eth0 - displays eth0 address and details ethtool eth0 - Query or control network driver and hardware settings ping host - Send ICMP echo request to host whois domain - Display whois info for domain dig domain - Display DNS info for domain Networking Cont'ddig -x IP_ADDRESS - Reverse lookup of IP_ADDRESS host domain - Display DNS ip address for domain hostname -I - Display all local ip addresses hostname -i - Display the network address of the host name netstat -nutlp - Display listening tcp and udp ports and programs Nano CommandsCtrl-R Read file Ctrl-O Save file Ctrl-X Close file Cut and Paste ALT-A Start marking text CTRL-K Cut marked text or line CTRL-U Paste text Navigate File ALT-/ End of file CTRL-A Beginning of line CTRL-E End of line CTRL-C Show line number CTRL-_ Go to line number Search File CTRL-W Find ALT-W Find next *CTRL-* Search and replace |
Cheatography
https://cheatography.com
System Admin C.S. JPLjr Cheat Sheet (DRAFT) by lapatchakjrj
A cheat sheet designed to help students learning system administration
This is a draft cheat sheet. It is a work in progress and is not finished yet.