Random Hints and Tips
From CafeWiki
An assortment of command and tips to do various interesting (and sometimes important) things on a linux box:
What CPU have I got?
$cat /proc/cpuinfo
How much memory?
$cat /proc/meminfo
More detailed CPU/system information?
$sudo lshw
What version of linux is this anyway (2 methods)?
$lsb_release –a $cat /etc/issue
Who are the users on the system?
$cat /etc/passwd
What groups are on the system?
$cat /etc/group
How is a user added? This can be tricky as there is an "adduser" command that works differently, in some cases, it might be even easier to just use the webmin interface if you have it installed.
$useradd username
How do I reboot the box from the CLI (2 methods)?
$sudo reboot $sudo shutdown -r 0
How to I (securely) copy a file from one server to another server? This works to send a file to another server as well, see this example. Switches are -p to preserve permissions and modification times, -r for recursive copying of a directory.
$scp [-p][-r] [[user@]from-host:]source-file [[user@]to-host:][destination-file]
How do I find previous commands in the history file? See this site for more examples.
$<ctrl-r>
(reverse-i-search)`red': [search-string] {left or right arrow allows edits}
$history | grep [search-string]
How do I execute a specific command from the history? (Once the command number is known, e.g. from grepping the history)
$![cmd-number]
How do I capture a command line session, both commands and responses (Ref)?
$script filename $<enter commands as desired> ... $ctrl-d <to exit>
