Musings

A random collection

Archive for the ‘linux’ Category

TECH: Enable SSHd on Fedora Linux (systemd)

Fedora now uses systemd package to manage service start ups. In order to enable sshd in it:

systemctl start sshd.service
systemctl enable sshd.service

Do not forget to fix iptables to allow ssh traffic. Add the following line in /etc/system/iptables file

-A INPUT -m state --state NEW -m tcp -p tcp -s 192.168.15.0/24 --dport 22 -j ACCEPT

Written by curious

November 12, 2011 at 10:54 pm

Posted in linux

TECH: Vim Folding

My ~/_vimrc file

set expandtab
set ts=4
set sw=4
set textwidth=80
set ai

au BufWinLeave * silent! mkview
au BufWinEnter * silent! loadview

set nobackup
set nowritebackup
set directory=c:\temp\junk
set viewdir=c:\temp\junk
  1. No tabs, just spaces
    set ts=4
    set sw=4
    set expandtab
    
  2. No backups, clean up swaps
    set nobackup
    set nowritebackup
    set directory=c:\temp
    
  3. Folding Commands
    zfNj creates a fold from the cursor down N lines
    zf/string creates a fold from the cursor to string
    za toggle fold at the cursor
    zj moves the cursor to the next fold
    zk moves the cursor to the previous fold
    zo opens a fold at the cursor
    zO opens all folds at the cursor
    zm increases the foldlevel by one
    zM closes all open folds
    zr decreases the foldlevel by one
    zR decreases the foldlevel to zero -- all folds will be open
    zd deletes the fold at the cursor
    zE deletes all folds
    [z move to start of open fold
    ]z move to end of open fold
    
  4. Automatically save folds. Put the following lines in your $HOME/.vimrc
    set viewdir=c:\temp
    
    au BufWinLeave * mkview
    au BufWinEnter * silent loadview
    
    or
    au BufWinLeave *notes.txt silent! mkview
    au BufWinEnter *notes.txt silent! loadview
    
  5. Running programs without having to press enter
    :silent !pdflatex -quiet %
    

    or better run it asynchronously

    :!start pdflatex -quiet %
    

Written by curious

April 27, 2011 at 9:10 am

Posted in linux

LINUX: Squid Logs

How can I print squid logs with nicer time stamps?

tail -f /var/log/squid/access.log|perl -p -e 's/^([0-9]*)/"[".localtime($1)."]"/e'

Written by curious

April 26, 2011 at 10:37 am

Posted in linux

TECH: Enable root login on GDM console

Comment out the following line in pam.d files:

  1. /etc/pam.d/gdm
    #auth       required    pam_succeed_if.so user != root quiet
    
  2. /etc/pam.d/gdm.password
    #auth       required    pam_succeed_if.so user != root quiet
    

Written by curious

October 20, 2010 at 1:20 pm

Posted in linux

TECH: wget — get past login page

  1. Form based login
    1. Create a wgetrc file:
      cookies=on
      keep_session_cookies = on
      save_cookies=~/cookies.txt
      load_cookies=~/cookies.txt
      
      inet4_only=on
      user_agent=Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2b5) Gecko/20091204 Firefox/3.6b5
      
    2. Now find out the URL to which you need to post login data from the <form> tag in the login page.
      Also find out all the fields that you need to post in the login request.

      wget http://foo.bar.com/login.php
      wget --post-data='sid=blabla&username=foobar&password=secret123' http://foo.bar.com/login.php
      wget http://foo.bar.com/a-protected-page.php
      
  2. Basic Authentication (using htaccess file)
    1. It is a lot simpler to take care of this one. You can just pass the user, password on the wget command line.
      wget -e 'robots=off' -k -m -np --http-user=foobar --http-passwd=secret123 http://foo.bar.com/basic/index.html
      
  3. Robots file bothering you. No problem, just tell wget to not to worry about it. Use -e ‘robots=off’ argument. Or put it in your wgetrc file.
    cookies=on
    keep_session_cookies = on
    save_cookies=~/cookies.txt
    load_cookies=~/cookies.txt
    
    inet4_only=on
    user_agent=Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2b5) Gecko/20091204 Firefox/3.6b5
    
    robots=off
    

Written by curious

October 7, 2010 at 9:57 am

Posted in linux

TECH: Simple Tricks on Linux

  1. Inserting a file in place of a pattern in another file
    # keep the line alongwith the pattern
    sed '/PATTERN/ r filename' inputfile > outputfile
    
    # replace the line with the pattern
    sed '/PATTERN/ {
      r filename
      d
    }' inputfile > outputfile
    

    Reference: http://www.grymoire.com/Unix/Sed.html

  2. GDM Console Root Login
  3. Setting up Caching DNS Server on Fedora
  4. wget — login page processing
  5. Enable access to user’s directory in HTTPd
    <IfModule mod_userdir.c>
        UserDir public_html
    </IfModule>
    
    <Directory /home/*/public_html>
        AllowOverride FileInfo AuthConfig Limit
        Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
        <Limit GET POST OPTIONS>
           Order allow,deny
            Allow from all
        </Limit>
        <LimitExcept GET POST OPTIONS>
            Order deny,allow
            Deny from all
        </LimitExcept>
    </Directory>
    
  6. Enable HTTPd password in Apache
    $ cat .htaccess
    AuthUserFile /home/adam/public_html/.htpasswd
    AuthType Basic
    AuthName "My Files"
    Require valid-user
    
    $ htpasswd -c .htpasswd username1
    
  7. List files with TimeStamp, PathName, Size (in bytes):
    find . -type f -printf "%TY/%Tm/%Td\t%TH:%TM:%TS\t%P
    
  8. VNC Server with GDM
  9. SELinux related commands
  10. Mounting Windows shares on Linux
  11. Connect to Databases using PHP
  12. Build Boost on Linux
  13. Accelerated Downloads on Linux
  14. Using GIT Version Control
  15. Join/Manipulate PDF Files
  16. Kill process tree
  17. Record Video on Linux
  18. Alpine with IMAP/GMAIL
  19. Basic MySQL Commands
  20. SSH Tunnel for Subversion
  21. Using screen on Linux

Written by curious

September 29, 2010 at 10:49 am

Posted in linux

TECH: VNC Server with GDM

  1. Install vnc-server
  2. Install xinetd
  3. Add VNC server to xinetd
    service vnc-server
    {
    disable = no
    socket_type = stream
    protocol = tcp
    group = tty
    wait = no
    user = nobody
    server = /usr/bin/Xvnc
    server_args = -inetd -query localhost -geometry 1024x800 -depth 16 -once -fp /usr/share/X11/fonts/misc -securitytypes=none
    }
    
  4. Enable XDMCP — edit /etc/gdm/custom.conf
    # GDM configuration storage
    
    [xdmcp]
    Enable = true
    
    [chooser]
    
    [security]
    DisallowTCP = false
    
    [debug]
    
  5. Start xinetd
  6. Now use VNC Viewer to connect to the VNC server to start using it.
  7. What you find a black blank screen? One possible reason is: You may not be running GDM. You might simply want to change your run-level to 5, if it is not that already

Written by curious

September 27, 2010 at 8:57 am

Posted in linux