2,187
edits
(→Unix User accounts: Added user and group bits) |
(→System Info: Added NIC list) |
||
(9 intermediate revisions by the same user not shown) | |||
Line 33: | Line 33: | ||
! Syntax !! Action / Description | ! Syntax !! Action / Description | ||
|- | |- | ||
|<code> ls -l </code> || List directory contents (<code>-l</code> long format) - see [[#Terminal Colours|Terminal Colours] | |<code> ls -l </code> || List directory contents (<code>-l</code> long format) - see [[#Terminal Colours|Terminal Colours]] | ||
|- | |- | ||
|<code> df -h </code> || Disk space summary | |<code> df -h </code> || Disk space summary | ||
Line 40: | Line 40: | ||
|- | |- | ||
|<code> du -sh </code> || Directory space usage summary | |<code> du -sh </code> || Directory space usage summary | ||
|- | |||
|<code> du -h --max-depth=1 </code> || Directory space usage summary of subfolders | |||
|- | |- | ||
|<code> <nowiki> du -ma / | sort -nr | head -n 20 </nowiki></code> || Find 20 largest files/directories | |<code> <nowiki> du -ma / | sort -nr | head -n 20 </nowiki></code> || Find 20 largest files/directories | ||
Line 56: | Line 58: | ||
|- | |- | ||
|<code> find <folder> -mtime +14 -exec rm {} \; </code> || Remove (delete) files in folder older than 14 days | |<code> find <folder> -mtime +14 -exec rm {} \; </code> || Remove (delete) files in folder older than 14 days | ||
|- | |||
|<code> find -iname 'file*' -mtime +7 -exec rm {} \; </code> || Remove all files matching ''file*'' in current folder older than 7 days | |||
|- | |||
|<code> find -iname 'file*' -exec rm {} \; -exec sleep 1 \; </code> || Remove all files matching ''file*'' in current folder, pausing for 1 sec between deletes | |||
|- | |- | ||
|<code> chmod +x <file> </code> || Add execute permission to a file | |<code> chmod +x <file> </code> || Add execute permission to a file | ||
Line 61: | Line 67: | ||
|<code> lsof <folder> </code> || List open files | |<code> lsof <folder> </code> || List open files | ||
|- | |- | ||
|<code> tar czf file.tgz folder </code> || Tar contents of folder to | |<code> lsof +L1 </code> || List deleted files still held open (reported by <code>df</code> but not <code>du</code> | ||
|- | |||
|<code> tar czf file.tgz folder </code> || [[Acronyms#T|Tar]] contents of folder (or file) to an archive | |||
|- | |||
|<code> mount --bind /var/tmp tmp </code> || Create a <code>/tmp</code> mount to local <code>/var/tmp</code> directory | |||
|} | |} | ||
Line 103: | Line 113: | ||
{|class="vwikitable" | {|class="vwikitable" | ||
|- | |- | ||
! File | ! File / Command !! Description | ||
|- | |- | ||
|<code> /proc/cpuinfo </code> | |<code> /etc/issue </code> || OS Name | ||
|- | |||
|<code> /proc/cpuinfo </code> || CPU(s) information - model, spec, features, etc | |||
|- | |||
|<code> lspci | egrep -i 'network|ethernet'</code> || List NICs | |||
|- | |- | ||
|} | |} | ||
Line 159: | Line 173: | ||
# If so, append the contents of the copied key to the file | # If so, append the contents of the copied key to the file | ||
# If not, copy the file | # If not, copy the file | ||
Alternatively... | |||
# On the local machine, be logged in as the same user as will be running the script | |||
# Create public key on local machine (just hit return to accept default options) | |||
#* <code> ssh-keygen -t rsa </code> | |||
# Copy key to remote machine | |||
#* <code>cat /root/.ssh/id_rsa.pub | ssh user@server "cat >> ~/.ssh/authorized_keys"</code> | |||
== VI Editor == | == VI Editor == | ||
Line 201: | Line 222: | ||
* '''List users''' - <code>cat /etc/passwd</code> | * '''List users''' - <code>cat /etc/passwd</code> | ||
* '''List groups''' - <code>cat /etc/group</code> | * '''List groups''' - <code>cat /etc/group</code> | ||
* '''Add user to group''' - <code> | * '''Show group membership''' - <code>id <user> </code> | ||
* '''Add user to group''' - <code>usermod -a -G <group> <user></code> - user must already exist | |||
[[Category: | [[Category:Linux]] |