Difference between revisions of "Linux"

Jump to navigation Jump to search
1,163 bytes added ,  08:30, 26 September 2016
→‎System Info: Added NIC list
m (→‎Unix User accounts: Added "Add user to group")
(→‎System Info: Added NIC list)
 
(8 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 file
|<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                               !! Description
! File / Command                            !! Description
|-
|-
|<code> /proc/cpuinfo </code>         || CPU(s) information - model, spec, features, etc
|<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 204: Line 225:
* '''Add user to group''' - <code>usermod -a -G <group> <user></code> - user must already exist
* '''Add user to group''' - <code>usermod -a -G <group> <user></code> - user must already exist


[[Category:Ubuntu]]
[[Category:Linux]]

Navigation menu