Linux Notes

The page is just here as a notebook for things I might otherwise forget...
nothing groudbreaking here, but it's useful to me.



FTP via a shell script
put this into the .netrc file

  machine foo.bar.com login myname password mypasswd
  macdef init
  put /home/myname/fubar.tar.gz backups/fubar.tar.gz
  bye

(2 blank lines at the end)

Then do command: ftp foo.bar.com
it'll auto connect and run the macro named 'init'
then quit...



How much Ram?

  cat /proc/meminfo
  cat /proc/cpuinfo

(/proc has lots of system info)

or:

  uname -a

also try:

  top
 
    or

  dmesg | more


Find out the BogoMIPS:

  dmesg | grep Bogo


Disk space:

  du

or:

  du -s -h

for 'summary' and 'human readable'





pre-login msg:

  /etc/issue.net

after login:

  /etc/motd



startup stuff: 

  /etc/rc.d
   rc.local
   rc.sysinit




start/stop sendmail (?)

  /etc/rc.d/init.d/sendmail stop
  /etc/rc.d/init.d/sendmail start



crontab fields:

  Field 1 - Minute (range: 0-59)
  Field 2 - Hour (range: 0-23)
  Field 3 - Day of the month (range: 1-31)
  Field 4 - Month of the year (range: 1-12)
  Field 5 - Day of the week (range: 1-7, where 1=Monday)
        
  0 9 * * 1-5
  (9:00 am, any date in the month, 
   every month, well, only Mon-Fri really ;)

The forward slash (/) can be used to specify step values. 
The value of an integer can be skipped within a range by 
following the range with /. For example, 0-59/2 can 
be used to define every other minute in the minute field. 
Step values can also be used with an asterisk. For instance, 
the value */3 can be used in the month field to run the task 
every third month.

      
  store in cron.file
  activate by command: crontab cron.file          

(some systems use crontab -e to edit the file...)


[p] 

The exec() function executes a system 
command AND NEVER RETURNS, unless 
the command does not exist and is executed 
directly instead of via /bin/sh -c (see below).  
Use system() instead of exec() if you want it to return.





smbclient  - let's you connect to an 
NT server using an FTP like app

  smbclient //SERVER/Volume -U username


  smbclient -M NetBIOS name

    This options allows you to sendk messages, using the
    "WinPopup" protocol, to another  computer.  Once  a
    connection  is  established you then type your mes[not equal]
    sage, pressing ^D (control-D) to end.

(Fun with NT users...)


Controlling apache:

 Restart:

   /etc/rc.d/init.d/httpd restart

 Start:

   httpd
  (See the Apache Documentation for all the command line flags.)

 Stop:

   kill -TERM `cat /usr/local/apache/logs/httpd.pid`






kernel version

  uname -a



lots of log info at:

  /var/log



problem: shutdown has no effect,  
try:

  shutdown -h now

this will 'halt' everything first...




Need to know the DHCP assigned ip address:

  /sbin/ifconfig



To get the current time: 

  date

To set the current time:

  date MMDDhhmm  (date 09190830 is Sept. 19, 8:30 AM)



List directories recursively

  find . -type d [-name <filename>]



Count files in directory:

  ls | wc -l







help me Tux!