Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Thursday, 5 July 2012

Unix --> Linux --> Android

What is Unix?
[From Wikipedia] Unix (officially trademarked as UNIX, sometimes also written as Unix) is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, Michael Lesk and Joe Ossanna. The Unix operating system was first developed in assembly language, but by 1973 had been almost entirely recoded in C, greatly facilitating its further development and porting to other hardware. Today's Unix system evolution is split into various branches, developed over time by AT&T as well as various commercial vendors, universities (such as University of California, Berkeley's BSD), andnon-profit organizations.
The Open Group, an industry standards consortium, owns the UNIX trademark. Only systems fully compliant with and certified according to the Single UNIX Specification are qualified to use the trademark; others might be called Unix system-like or Unix-like, although the Open Group disapproves[1] of this term. However, the term Unix is often used informally to denote any operating system that closely resembles the trademarked system.
During the late 1970s and early 1980s, the influence of Unix in academic circles led to large-scale adoption of Unix (particularly of the BSD variant, originating from the University of California, Berkeley) by commercial startups, the most notable of which are Solaris, HP-UX and AIX, as well as Darwin, which forms the core set of components upon whichApple's OS X, Apple TV, and iOS are based.[2][3] Today, in addition to certified Unix systems such as those already mentioned, Unix-like operating systems such as MINIX, Linux, Android, and BSD descendants (FreeBSD, NetBSD,OpenBSD, and DragonFly BSD) are commonly encountered. The term traditional Unix may be used to describe an operating system that has the characteristics of either Version 7 Unix or UNIX System V
What are other unix-like operating systems?
Linux (including all its flavours eg, Redhat, Suse, Ubuntu, Centos, Debial etc)
Android
BSD (OpenBSD, FreeBSD etc)


Apple Mac OS (including iOS)
Apple's operating systems are derived from Unix, therefore they share a lot of features with Linux and other Unix/Unix-like operating systems.


Where is Linux used
Linux is, and has been the main driver of Internet (servers) for decades. It is the most used operating system in Servers (behind the scenes stuff) with Windows being the most popular for Client systems (Personal computers and desktops)
There are some upcoming popular Linux Desktops eg. Ubuntu


Linux, just as its parent Unix, has given birth to its own set of various derivatives like Android
Because Linux is highly customization, a lot of hardware manufacturers have used it as the operating system in their electronic products. Because these products are specialised (one task) computers, this operating system within them is generally know as the firmware


Firmware for many networking (internet) capable hardware devices use Linux
eg. Routers, TVs, Portable Media Players, Soft Phones all use some form of Linux at the core of its operations.
Some sensor devices like the Zigbee sensors also use some form of Linux as their central system
A majority of mobile phones (both feature and smartphones) use a derivative of Unix/Linux as their operating systems


Why Linux is so popular, whilst little known
Linux is like underwear in our life. Its necessary and everyone subtly uses one, without thinking about it, but there are great companies producing these undergarments around the clock. You have freedom to wear the one you like, that suits your needs, or even to modify at will. You have choice to have the very cheap (or free) yet functional ones, or flashy brands according to your taste. Most people who use Linux say the major thing about is "Freedom" Whatever that means, Linux is a basic component of our modern technologies.

Thursday, 29 March 2012

Simple straight forward install of Nvidia graphics drivers on Centos6

echo -e "\nblacklist nouveau" >> /etc/modprobe.d/blacklist.conf file [[or let the nvidia installer do the job]]
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
dracut -v /boot/initramfs-$(uname -r).img $(uname -r)
init 6 [[and reboot to runlevel 3]]
./NVIDIA-Linux-x86_64-295.33.run -s -n -X --kernel-source-path=/usr/src/kernels/$(uname -r)/  [[use appropriate driver and also check your kernel-source-path]]

Monday, 25 April 2011

My SELinux Quick Reference

tested for RHEL/Centos 5

Check status of selinux
sestatus

List security context of file and/or directories
ls -Z /dir

List security context of a/processes
ps axZ | proc

Change security context for a file/dir
chcon -Rv --type=proc_sys_content_t /dir (reboot persistent)
semanage fcontext -a -t proc_sys_content_t "/dir(/.*)?" (filesystem relable persistent)

Restore security contect of a file/dir
restorecon -Rv /dir/subdir

Allow access to a port, eg.
semanage port -a -t http_port_t -p tcp 81

Toggling SELinux policies with boolean commands;
see this wiki


When you are hitting a security restriction in your server that's being enforced by SELinux (in enforcing mode) You can troubleshoot such issues by first setting selinux to permissive and check the audited security context breaches.
setenforce 0

If SELinux (in permissive mode) is complaining about a specific process' access to files(/var/log/audit/audit.log), we can resolve these issues by reviewing what SELinux would have wanted inorder to allow access. e.g for snmpd:
grep snmpd_t /var/log/audit/audit.log | audit2allow -r

If the results look reasonable, then make custom policy module to allow the actions;
grep snmpd_t /var/log/audit/audit.log | audit2allow -M snmpdlocal

and then load the module
semodule -i snmpdlocal.pp

then check if module is loaded correctly
semodule -l

Monitor the audit.log to see if issue is resolved. If all looks ok, then revert your SELinux to enforcing
setenforce 1

Tuesday, 1 February 2011

Configuring squid proxy for ldap authentication

This article is intended for someone with prior knowledge of how squid proxy server works. It seeks to summarise and simplify the process of configuring squid to authenticate against an ldap directory and possibly setup access controls to web resources against ldap groups.

Note that you probably need kernel-devel openldap-devel packages on your system.

Make sure that your squid is compiled with ldap support. If not already so, you can reconfigure your squid by re-running './configure' as follows:

]# ./configure --sysconfdir=/etc/squid --bindir=/usr/sbin --includedir=/usr/include --localstatedir=/var --with-logdir=/var/log/squid --datadir=/usr/share --libexecdir=/usr/lib/squid --enable-basic-auth-helpers="LDAP MSNT NCSA" --enable-external-acl-helpers="ip_user ldap_group unix_group wbinfo_group"


Then in your squid.conf you should configure authentication by modifying the auth paragraph/directives

auth_param basic program /usr/lib/squid/squid_ldap_auth -b "ou=yourou,o=yourorg" -f "uid=%s" -h your_ldap_server.domain.com
auth_param basic children 10
auth_param basic realm "Domain.Org Proxy-Cache"
auth_param basic credentialsttl 5 minutes


To be able to filter users with ldap groups, you need to configure external acl like:

external_acl_type ldap_groups %LOGIN /usr/lib/squid/squid_ldap_group -b "ou=your_ou,o=your_org" -f "(&(cn=%g)(memberUid=%u))" -h your_ldap_server.domain.com


On the acls, you specify the handle for your auth

acl ldap_authenticated proxy_auth REQUIRED
acl allowed_groups external ldap_groups mygroup
acl subnet1 src 10.0.0.0/255.255.0.0


Then finally on the http_access section:

http_access allow subnet1 ldap_authenticated allowed_groups


Here, you should remember that squid access rules are read sequencially top-down and when a match is found, processing stops. so the order of your access/deny directives matter very much.
The above statement matches all users in subnet1 who are successfully authenticated and belong to ldap group 'mygroup'

Test your setup to see if auth is working ok, On the command prompt run:
/usr/lib/squid/squid_ldap_auth -b "ou=yourou,o=yourorg" -f "uid=%s" -h your_ldap_server.domain.com

and supply a username 'space' password
If it returns 'OK' then your auth is setup ok. Make sure there is only a single space between username and password

As a bonus: you may consider immunising your squid conf
]# chattr +i /etc/squid/squid.conf


This has been tested against Centos 5.3 squid-3.0.STABLE12 installed from source.

Wednesday, 26 August 2009

My ~]# ./Shell One Liners

This is going to be a long list of some of the shell one liners that I have used at one time in my *nix life.

1. ps axho args | awk /ssh/'{print $1}'
2. for i in AIX*; do mv $i BSD${i:3}; done ## or u can use {i#AIX}
3. sed -i s/AIX/BSD/ BSD*
4. kill `ps aux | awk /$1/'{if ($3+0>'"$limit"') {print $2} }'`
5. for i in *.frm; do touch ${i%.frm}.{MYD,MYI}; done
6. awk '/^iface bar/,/^$/ {print}'
7. find /home/ -name '*:*' -exec rename s/:/-/ {} \;
8. sed '/^$/d' /path/to/currentfile | sed '1,8d' | sed 'N;$!P;$!D;$d' > /path/to/newfile
9. find /mytopdir -depth -type d -empty -exec rmdir {} \;
10. find . -type f -newermt 2007-06-07 ! -newermt 2007-06-08
11. find ./ -type f -ls |grep '19 Jun'
12. find . -type f -mtime $(( ( $(date +%s) - $(date -d '2010-06-25' +%s) ) / 60 / 60 / 24 - 1 ))
13. ifconfig -a | grep inet | grep -v '127.0.0.1' | awk '{ print $2}'
14. sed -i 's/StringA/StringB/g' ` grep -ril 'StringA' /homes/myhome/* ` 
15. find / -cmin -1440 -size +5000000c -print
16. for i in `ls /homes/`; do find /homes/$i/ -name "*R3D*" -mtime +730 -exec rm {} \;; done
17. cd /home/user && rename : _ *:*
18. for i in `find /home/user/ -name '*:*' -print`; do mv $i ${i//:/_}; done