You are not logged in.
so when i started out using Linux some time ago (how long has it been?) i read lots and lots of stuff, and come across lots and lots of commands. i figured i wasn't going to remember them all, so i made a reference script for this. the script is called 'system'. just typing 'system' will give you some information on your system. 'system help' will provide you with the other options, which are:
-- use 'system [ref|dir|sh|apps]' --'system ref' is a reference to various commands/apps/functions. 'system dir' displays the general Linux filesystem-structure. 'system sh' displays some standard bash-stuff. 'system apps' displays a list of apps that i tend to forget about.
all of these work on commands and text-files holding the information. this script saves me from having to resort to Google for the same kinda thing each time. seeing how others might find something like this useful as well, i decided to share it here.
#!/bin/bash
if [ ! $1 ]; then
echo "--- [system information] [`date +%H:%M` @ `date +%d.%m.%Y`] ---"
echo
echo "`uname -n` `uname -r` (`uname -v`)"
echo "Machine Hardware: `uname -m` | Processor: `uname -p` | Hardware Platform: `uname -i`"
echo "Uptime:`uptime`"
echo "Window Manager: $DESKTOP_SESSION"
echo
cat /proc/cpuinfo | grep -m 1 "cpu cores"
cat /proc/cpuinfo | grep -m 1 "name"
cat /proc/cpuinfo | grep -m 1 "flags"
echo
echo "--- [/system information] ---"
exit
fi
if [ $1 == "ref" ]; then
echo "--- [system information reference] [`date +%H:%M` @ `date +%d.%m.%Y`] ---"
cat ~/scripts/system_ref/reference.txt
exit
elif [ $1 == "dir" ]; then
cat ~/scripts/system_ref/linux_filesystem.txt | awk -F: '{printf "%-10s %1s %1s\n", $1,$2,$3}'
exit
elif [ $1 == "sh" ]; then
echo "--- [shell commands] ---"
cat ~/scripts/system_ref/shell_commands.txt | awk -F".;" '{printf "%-10s %s\n", $1,$2}'
exit
elif [ $1 == "apps" ]; then
echo "--- [apps reference] ---"
cat ~/scripts/system_ref/apps.txt
exit
else
echo "-- use 'system [ref|dir|sh|apps]' --"
fithe .txt-files used by the various options are in a folder called 'system ref'. here's the files.
# apps.txt
wc word count
tr trim whitespace
sed stream editor
awk column operations
rsync synchronize directories
find use find [dir] [term]
abcde cd rip
# shell_commands.txt
>.;Redirect output
>>.;Append to file
<.;Redirect input
<<.;"Here" document (redirect input)
|.;Pipe output
&.;Run process in background.
;.;Separate commands on same line
*.;Match any character(s) in filename
?.;Match single character in filename
[ ].;Match any characters enclosed
[!].;Match any characters except those enclosed
( ).;Execute in subshell
` `.;Substitute output of enclosed command
" ".;Partial quote (allows variable and command expansion)
' '.;Full quote (no expansion)
\.;Quote following character
$var.;Use value for variable
$$.;Process id
$0.;Command name
$n.;nth argument (n from 0 to 9)
$*.;All arguments as a simple word
# .;Begin comment
bg.;Background execution
break.;Break from loop statements
cd.;Change directories
continue.;Resume a program loop
echo.;Display output
eval.;Evaluate arguments
exec.;Execute a new shell
fg.;Foreground execution
jobs.;Show active jobs
kill.;Terminate running jobs
newgrp.;Change to a new group
shift.;Shift positional parameters
stop.;Suspend a background job
suspend.;Suspend a foreground job
time.;Time a command
umask.;Set or list file permissions
unset.;Erase variable or function definitions
wait.;Wait for a background job to finish
# linux_filesystem.txt
/ root
/bin & /usr/bin user binaries
/boot boot loader files (grub, startup files, kernel)
/dev device files
/etc configuration files
/etc/init.d startup programs directory
/etc/fstab filesystem mounting config file
/etc/passwd password information file
/home home directories
/lib system libraries
/lost+found recovery files
/media removable devices
/misc miscellaneous files
/mnt mount directory (default)
/opt optional add-on apps
/proc process information (see proc.txt)
/root root's home directory
/sbin & /usr/sbin system binaries
/selinux security-enhanced linux
/srv service data
/sys driver directories
/tmp temporary files (cleaned on reboot)
/usr user programs
/usr/doc documentation files
/usr/share config files + graphics
/usr/src source code files
/usr/include header files
/usr/X11 X window system files
/usr/local local user programs
/var variable files
/var/log system log files
/var/spool queued process files (printer)
# reference.txt
cat /proc/cpuinfo - info on the CPU
(to find out the meaning of the cpu flags, check out /usr/src/linux-headers-2.6.32-5-common/arch/x86/include/asm/cpufeature.h)
printenv - print all environment variables
/proc/modules, lsmod - list all loaded modules.
/sbin/modinfo <module> - detailed info on module
lspci - list all PCI devices.
lsusb - info on USB ports.
lshw - info on hardware, also try 'sudo dmidecode'.
hwinfo --short - more info on hardware.
inxi - system info
df, sudo blkid, fdisk -l - info on partitions.
dmesg - retrieve the boot-log.
chkconfig --list - list startup services.
ps, pstree, top - get overview of processes.
arp, nmap, fuser - info on network, ports etc.
ifconfig, iwconfig, rfkill - networks/wireless
traceroute [website] - see the route to a site
cat /etc/X11/default-display-manager - get default Display Manager.
dpkg -l, apt-show-versions - list of installed apps.
strings [example: /bin/bash] - print all readable lines in a program.
bc - a CLI calculator.
trap -l - a list of possible signals.
type [command] - see the type of command.
set | more - show the user environment.
strace - trace the calls for an app (debug)
For a summary of the directory structure, use 'system dir'.
For some general shell features, use 'system sh'.
To configure printers, go to http://localhost:631 or use system-config-printer
For a list of fonts, do: fc-list | sed 's,:.*,,' | sort -u
Kernel Documentation: http://kernel.org/doc/Documentation/
Linux Command Reference: http://www.perpetualpc.net/srtd_commands_rev.htmlthough i've shown them in a single code-box here, each is a separate file, as you can see from the 'system' bash-script.
so, hope someone is helped by this in any way.
Offline
Hi rhowaldt, thanks for your script.
One thing: should the single 'equals sign' indeed be '==' ? I get 'unexpected operator errors' when I use double equals sign (lines 17, 21 etc.)
Start Distrohopping here! -> Break your own...
VSIDO
LinuxCNC
Frugalware <- It's all just a kernel.
Offline
@machinebacon: thanks man. no i think it should be '-eq' instead of '=='. i think luc or chaanakaya already pointed this out to me in a different thread, but this script just works and am not actively working on the bash-part of it so never thought of changing that actually.
to be ahead of other scripters here: it would be nicer to use 'case' instead of the 'if/elif/elif/elif' construct. the reasons for not doing that are the same as above.
anyway, the whole point here is sharing a way of getting system info and sharing an idea of setting up a personal reference through a simple bash-script. i think the script is so simple that many beginners can grasp it and recreate it themselves without too much trouble. this is what i find of real importance here.
now another discussion would be whether i'm teaching bad scripting here, but at least we addressed the 'mistakes' in this post :)
Last edited by rhowaldt (2011-10-17 19:36:48)
Offline
Right! == for bash, = for sh
Sorry to bother 
Start Distrohopping here! -> Break your own...
VSIDO
LinuxCNC
Frugalware <- It's all just a kernel.
Offline
just found out it shouldn't be '-eq' instead of '==' ... -eq expects and integer (number), and i'm using strings (characters) so that won't work.
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.