Wednesday, July 1, 2009

Commands related to Process Control

Here "PID" is refer to the process ID, that you can get from command "ps -aux"



#fg PID
It Brings a background or stopped process to the foreground.


#bg PID
It sends the process to the background.


#any command &
Run any command in the background (the symbol "&" means "run the proceeding command in the background").


#batch any command
Run any command when the system load is low. I can logout and the process will keep running.


#at 18:00
Execute a command at a specified time. You will be prompted for the command(s) to run, until you press d.


#kill PID
To shutdown process by force. First determine the PID of the process to kill using ps.


#killall program name
Kill program(s) by name.


#nice program_name
Run program name adjusting its priority. The priority value may be in the range -20 to 19. Only root may specify negative values. Use "top" to display the priorities of the running processes.


#renice -1 PID
(as root) Change the priority of a running process to -1. Normal users can only adjust processes they own, and only up from the current value (make them run slower).

Useful commands for Ubuntu

Privileges Commands

sudo command - run command as root
sudo su – root shell open
sudo su user – open shell as a user
sudo -k – forget your password sudo
gksudo command – sudo visual dialog (GNOME)
kdesudo command – sudo visual dialog (KDE)
sudo visudo – edit / etc / sudoers
gksudo nautilus – root file manager (GNOME)
kdesudo konqueror – root file manager (KDE)
passwd – change your password

Network Commands


ifconfig – displays information network
iwconfig – displays information from wireless
sudo iwlist scan – scan wireless networks
sudo /etc/init.d/networking restart – reset the network
(file) /etc/network/interfaces – manual configuration
ifup interface – bring online interface
ifdown interface – disable interface

Display Commands

sudo /etc/init.d/gdm restart – reset X (Gnome)
sudo /etc/init.d/kdm restart – reset X (KDE)
(file) /etc/X11/xorg.conf – show Configuration
sudo dpkg-reconfigure - reconfigure xserver-xorg-phigh - reset configuration X
Ctrl+Alt+Bksp – X display reset if frozen
Ctrl+Alt+FN – switch to tty N
Ctrl+Alt+F7 – switch back to X display

Service System Commands.

start service – service to start work (Upstart)
stop service – service to stop working (Upstart)
status service – check if service is running (Upstart)
/etc/init.d/service start – start service (SysV)
/etc/init.d/service stop – stop service (SysV)
/etc/init.d/service status – check service (SysV)
/etc/init.d/service restart – reset service (SysV)
runlevel – get current runlevel

Firewall related commands

ufw enable – turn on the firewall
ufw disable – turn off the firewall
ufw default allow – allow all connections by default
ufw default deny – drop all connections by default
ufw status – current rules and
ufw allow port – to allow traffic on port
ufw deny port – port block
ufw deny from ip – ip block

System Commands.


lsb_release -a – get the version of Ubuntu
uname -r – get kernel version
uname -a – get all the information kernel

Commands for Package Manager.


apt-get update – refresh updates available
apt-get upgrade – update all packages
apt-get dist-upgrade – version update
apt-get install pkg – installing pkg
apt-get remove pkg – uninstall pkg
apt-get autoremove – removing packages obsotletos
apt-get -f install – try to fix packages
dpkg –configure -a – try to fix a broken package
dpkg -i pkg.deb – install file pkg.deb
(file) /etc/apt/sources.list – list of repositories APT

Commands Special Packages.

ubuntu-desktop – Setting the standard Ubuntu
kubuntu-desktop – KDE Desktop
xubuntu-desktop – desktop XFCE
ubuntu-minimal – core earnings Ubuntu
ubuntu-standard – the standard utilities Ubuntu
ubuntu-restricted-extras – not free, but useful
kubuntu-restricted-extras – ditto KDE
xubuntu-restricted-extras – ditto XFCE
build-essential – packages used to compile
linux-image-generic – latest generic kernel image
linux-headers-generic – latest headlines

Applications commands.

nautilus – File Manager (GNOME)
dolphin – File Manager (KDE)
konqueror – Web browser (KDE)
kate – text editor (KDE)
gedit – text editor (GNOME)

Useful 100+ Linux commands

1. Schedule a queue to run at 9am on March 1st. Note: Ctrl-d to save and exit.

# at 9am March 1

2. Schedule a queue to run after 5 minutes.

# at now +5 minutes

3. Check any jobs pending to run, same as at -l .

# atq

4. Empty out a file.

# cat /dev/null > /path/to/file

5. Change directory, see also pushd and popd.

# cd

6. List run level information for the service type.

# chkconfig --list

7. Change owner recursively.

# chown -R : /path/to/directory

8. Change shell.

# chsh

9. Scan recursively for viruses.

# clamscan -r

10. Compare two files.

# cmp file1 file2

11. Copy keeping the directory structure.

# cp --parent /source/path /destination/path

12. Copy keeping the permissions of the user.

# cp -p

13. Copy recursive.

# cp -r

14. Copy without shell aliasing.

# \cp

15. List crontab for user.

# crontab -u -l

16. Check current date and time.

# date

17. Set current date and time, may need to set the hardware clock to the system time too, `man hwclock`.

# date -s 'Wed May 28 11:35:00 EST 2003'

18. Show disk free in human readable format.

# df -h

19. Configure interface using DHCP protocol.

# dhclient eth0

20. Find context differences between two files.

# diff -c

21. Creating a patch file.

# diff -Naur oldDir/oldFile newDir/newFile > new_patchFile

22. Kernel buffer

# dmesg

23. Show disk used in human readable format.

# du -h /path/to/directory

24. Find files larger than 10MB.

# find /path/to/file -size +10000k

25. Find file permissions with setuids.

find / \( -perm -4000 -o -perm -2000 \) -exec ls -ldb {} \;>> /tmp/suids

26. Search for world writable files and directories.

# find / -perm -002

27. Display information on free and used memory.

# free

28. Grep on word boundaries.

grep -w

29. Count the number of mathces - similar to “wc -l”.

# grep -c

30. Perform timings of device reads for benchmark and comparison purposes.

# hdparm -t /dev/hda1

31. Set the hardware clock to the current system time.

# hwclock --systohc

32. check the ip address

# ifconfig

33. Add an  ip address to eth0.

# ifconfig eth0:x xxx.xxx.xxx.xxx

34. Install loadable kernel module. You can also use `modprobe` to do the same.

# insmod

35. Displays information about your system’s CPU and I/O.

# iostat [ interval [ count ] ]

36. List iptables firewall rules in numeric format.

# iptables -L -n

37. HangUP process so it will re-read the config file.

# killall -HUP

38. Install the boot loader and increase verborsity.

# lilo -v -v

39. Query the boot map.

# lilo -q

40. One time boot to the named kernel.

# lilo -R

41. Create symbolic link to the target file or directory.

# ln -s

42. Configure dynamic linker run-time bindings

# ldconfig

43. List the IPs bound via Ensim

# listaliases

44. Quickly search for indexed files. Run `updatedb` to update the indexed database.

# locate

45. List files.

# ls

46. List loaded kernel modules

# lsmod

47. Create the access.db file database map for sendmail.

# makemap hash /etc/mail/access.db < /etc/mail/access

48. Create/Make a new directory.

# mkdir

49. Generate a random 128 character length password.

# mkpasswd -l 128

50. Read in the contents of your mbox (or the specified file).

# mail -f /var/mail/nameOfFile

51. Print the mail queue

# mailq

52.

# mailstat /path/to/procmail/log

53. Description of the hierarchy directory structure of the system

# man hier

54. Check the MD5 message digest.

# md5sum

55. Mount points check.

# mount

56. Provide information about your systems’ processor.

# mpstat [ interval [ count ] ]

57.

# ncftpget -R -u  -p
hostname /local_dir /remote_dir

58.

# netstat -a | grep -i listen

59. Will show you who is attached to what port.

# netstat -anpe

60.

# netstat -n

61. See which programs are listening on which port

# netstat -lnp

62. Will show you what local TCP ports are open and what programs are running on them.

# netstat -lntpe

63. Will show you what local UDP ports are open and what programs are running on them.

# netstat -lnupe

64. Run a program with modified scheduling priority. (# range between -20 to +20, negative is higher priority)

# nice -n # [command to nice]

65. Scan network

# nmap -v hostname/ip

66. Patch and keep a backup

# patch -p# -b < patch_file

67.

# ps -ecaux

68. Turn off all quotas for users and groups, verbose mode

# quotaoff -augv

69. Check quota for all users and groups interactively, do quotaoff first.

# quotacheck -augmiv

70. Turn on all quotas for users and groups

# quotaon -augv

71. Add host ip to route on a particular device.

# route add -host xxx.xxx.xxx.xxx dev eth0:x

72.

# rdate

73. Remove file

# rm

74. Remove kernel module

# rmmod

75. Display the routing table in numeric.

# route -n

76.

# rpm

77. Uninstall/erase package.

# rpm -e

78. Erase without dependency check.

# rpm -e --nodeps

79. List out installed rpms by date, latest on top.

# rpm -qa --last | less

80. Rebuild rpm database.

# rpm --rebuilddb

81. Find which package owns the file.

# rpm -qf /path/to/file
# rpm -q --whatprovides /path/to/file

82. Verify package.

# rpm -V

or

# rpm -Vf /path/to/file

83. Locate documentation for the package that owns the file.

# rpm -qdf /path/to/file

84. Query information on package.

# rpm -qip

85. Query files installed by package.

# rpm -qlp

86. Gives list of files that will be installed/overwritten.

# rpm -ql

87. Will show the scripts that will be executed.

# rpm -q --scripts

88. Display system activity information

# sar

89. Print a 0 padded sequence of numbers.

# seq -w 1 10

90. Record eveything printed on your terminal screen.

# script -a

Ctrl+D to exit out. `more ` to view.

91. Check the status of a service.

# service status

92. Restart after shutdown and force fsck (fsck may take a while).

# shutdown -rF now

93. Split a file into pieces with numeric suffixes, so it can be burnt to cds.

# split -d -b 640k big_input_filename.gz piece_file_prefix.gz.

To piece it back you can `cat piece_file_prefix.gz.* > original.gz`
94. Determine if a network service binary is linked againt tcp wrapper, libwrap.a

# strings -f | grep hosts_access

96. how to use tar

# tar -cvzf fileName.tar.gz `find /file/path -mtime -1 ! -type d -print`

97.

# tar -xvzpf fileName.tar.gz /path/to/file.txt

98. How to use tcpdump

# tcpdump -i eth0 dst port 80 | more

99. System process status

# top

100. View the full command line.

# top -c

101. Create empty file of 0 byte

# touch

102. Similar to `which` - shows full path to the command.

# type

103. Check the limit of user

# ulimit -a

104. Check the version of kernel running

# uname -a

105. Update package profile with rhn

# up2date -p

106. Install package via up2date.

# up2date -i

107.

# uptime

108.

# usermod

109. Utility reports virtual memory statistics

# vmstat [second interval] [no. of count]

110. Show who is logged on and what they are doing.

# w

111. Periodically watch output of a command in full screen

# watch ''

112. Run and generate the apache reports using webalizer

# webalizer -c /path/to/webalizer.conf

113. Recursive download of a url, converting links, no parent.

# wget -r -k -np

114. Mirror, convert links, backup original, dynamic to html and output a “logFile”.

# wget -m -k -K -E -o [logFile]

115. Locate the binary, source, and manual page files for a command.

# whereis

116. Shows the full path of command.

# which

117. Show who is logged on.

# who

118. Yum package updates

# yum check-update           -- check to see what updates are needed
# yum info     -- show basic information about a package
# yum update   -- update particular package

119. Control jobs:

# Ctrl-z   -- suspend foreground job
# jobs     -- list jobs
# bg       -- send job to background
# fg       -- bring job to foreground

Check your Disk Performance

Using some simple command you can check the performance of hard disk

#hdparm -tT /dev/sda

Output:


/dev/sda:

Timing cached reads:   6054 MB in  2.00 seconds = 3028.86 MB/sec

Timing buffered disk reads:   42 MB in  3.09 seconds =  13.60 MB/sec

/dev/sda:

Timing cached reads:   6054 MB in  2.00 seconds = 3028.86 MB/sec

Timing buffered disk reads:   42 MB in  3.09 seconds =  13.60 MB/sec

Monday, June 22, 2009

Setup OpenLDAP Server+OpenLDAP Client+Samba+auto mount in Ubuntu 9.04

Installation Setup Scenario.

I have setup one machine as a openldap server and one machine as a openldap client.

I have setup openldap server & samba server in one machine.

Machine 1 : Openldap server + Samba Server

Hostname : openldap.server

IP : 10.8.0.12

Machine 2 : Openldap Client

Hostname : openldap.client

IP : 10.8.0.15

Configure OpenLDP server




Step 1 :  Installation of required packages

First, install the OpenLDAP server daemon slapd and ldap-utils, a package containing LDAP management utilities:

#apt-get install slapd ldap-utils

Step 2 : Configure slapd

# dpkg-reconfigure slapd

It will prompt you for server questions.

1.  No

2. DNS domain name: openldap.server

3.Name of your organization: openldap.server

4.Admin password: 12345

5.Confirm password: 12345

6.OK

7.HDB

8. No

9. Yes

10.No

Step 3 : Test Configuration.

Use ldapsearch to view the tree, entering the admin password set during installation or reconfiguration:

# ldapsearch -xLLL -b cn=config -D cn=admin,cn=config -W olcDatabase={1}hdb

Enter LDAP Password:

dn: olcDatabase={1}hdb,cn=config

objectClass: olcDatabaseConfig

objectClass: olcHdbConfig

olcDatabase: {1}hdb

olcDbDirectory: /var/lib/ldap

olcSuffix: dc=openldap,dc=server

olcAccess: {0}to attrs=userPassword,shadowLastChange by dn="cn=admin,dc=exampl

e,dc=server" write by anonymous auth by self write by * none

olcAccess: {1}to dn.base="" by * read

olcAccess: {2}to * by dn="cn=admin,dc=openldap,dc=server" write by * read

olcLastMod: TRUE

olcDbCheckpoint: 512 30

olcDbConfig: {0}set_cachesize 0 2097152 0

olcDbConfig: {1}set_lk_max_objects 1500

olcDbConfig: {2}set_lk_max_locks 1500

olcDbConfig: {3}set_lk_max_lockers 1500

olcDbIndex: objectClass eq

Step 4 : Add new schema using ldif file.

  • First, create a conversion schema_convert.conf file containing the following lines:


#vi schema_convert.conf

include /etc/ldap/schema/core.schema

include /etc/ldap/schema/collective.schema

include /etc/ldap/schema/corba.schema

include /etc/ldap/schema/cosine.schema

include /etc/ldap/schema/duaconf.schema

include /etc/ldap/schema/dyngroup.schema

include /etc/ldap/schema/inetorgperson.schema

include /etc/ldap/schema/java.schema

include /etc/ldap/schema/misc.schema

include /etc/ldap/schema/nis.schema

include /etc/ldap/schema/openldap.schema

include /etc/ldap/schema/ppolicy.schema

  • Next, create a temporary directory to hold the output


#mkdir /tmp/ldif_output

  • Now using slaptest convert the schema files to LDIF


# slaptest -f schema_convert.conf -F /tmp/ldif_output

  • Edit the /tmp/ldif_output/cn=config/cn=schema/cn={8}misc.ldif file, changing the following attributes


#vi /tmp/ldif_output/cn=config/cn=schema/cn={8}misc.ldif

dn: cn=misc,cn=schema,cn=config

...

cn: misc

And remove the following lines from the bottom of the file

structuralObjectClass: olcSchemaConfig

entryUUID: 10dae0ea-0760-102d-80d3-f9366b7f7757

creatorsName: cn=config

createTimestamp: 20080826021140Z

entryCSN: 20080826021140.791425Z#000000#000#000000

modifiersName: cn=config

modifyTimestamp: 20080826021140Z

  • Finally, using the ldapadd utility, add the new schema to the directory


# ldapadd -x -D cn=admin,cn=config -W -f /tmp/ldif_output/cn\=config/cn\=schema/cn\=\{8\}misc.ldif

Step : 5 Create Test account

#vi test_account.ldif

dn: ou=people,dc=openldap,dc=server

objectClass: organizationalUnit

ou: people

dn: ou=groups,dc=openldap,dc=server

objectClass: organizationalUnit

ou: groups

dn: uid=test,ou=people,dc=openldap,dc=server

objectClass: inetOrgPerson

objectClass: posixAccount

objectClass: shadowAccount

uid: test

sn:

givenName: Test

cn: Test

displayName: Test

uidNumber: 1000

gidNumber: 10000

userPassword: password

gecos: Test

loginShell: /bin/bash

homeDirectory: /home/test

shadowExpire: -1

shadowFlag: 0

shadowWarning: 7

shadowMin: 8

shadowMax: 999999

shadowLastChange: 10877

mail: test@openldap.server

postalCode: 31000

l: Toulouse

o: Openldap

mobile: +33 (0)6 xx xx xx xx

homePhone: +33 (0)5 xx xx xx xx

title: System Administrator

postalAddress:

initials: JD

dn: cn=openldap,ou=groups,dc=openldap,dc=server

objectClass: posixGroup

cn: openldap

gidNumber: 10000

Save the file.

#ldapadd -x -D cn=admin,dc=example,dc=com -W -f test_account.ldif

We can check that the content has been correctly added with the tools from the ldap-utils package. In order to execute a search of the LDAP directory:

#ldapsearch -xLLL -b "dc=openldap,dc=server" uid=test sn givenName cn

dn: uid=test,ou=people,dc=openldap,dc=server

cn: test

sn:

givenName: test

Configure OpenLDAP Client


Step 1 : Install Required packages

#apt-get install libnss-ldap smbfs

During the install a menu dialog will ask you connection details about your LDAP server.

Should debconf manage LDAP configuration?: Yes

LDAP server Uniform Resource Identifier: ldap://10.8.0.12

Distinguished name of the search base: dc=openldap,dc=server

LDAP version to use: 3

Make local root Database admin: Yes

Does the LDAP database require login? No

LDAP account for root: cn=admin,dc=openldap,dc=server

LDAP root account password: 12345



Step 2 : Backup useful files

# cp /etc/nsswitch.conf /etc/nsswitch.conf.org

# mkdir /root/pam.d_backup

# cp /etc/pam.d/* /root/pam.d_backup/

Step 3 : Enable the auth-client-config LDAP profile

#auth-client-config -t nss -p lac_ldap

  • -t: only modifies /etc/nsswitch.conf.

  • -p: name of the profile to enable, disable, etc.

  • lac_ldap: the auth-client-config profile that is part of the ldap-auth-config package.


Step 4 : Configure the system to use LDAP for authentication

#pam-auth-update

Step 5 : Reboot the system

#reboot

Step 6 : Test OpenLDAP connection

#getent passwd

Above command will show the passwd file of Openldap server. If you see the account “test” which we have created in the OpenLDAP server then it shows that authentication working fine with OpenLDAP server. Try to ssh using test user on client machine.

Configure SAMBA server


Step 1 : Install required packages.

#apt-get install samba samba-doc smbldap-tools

Step 2 : OpenLDAP Configuration

Schema file needs to be unzipped and copied to /etc/ldap/schema.

# cp /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz /etc/ldap/schema/

#gzip -d /etc/ldap/schema/samba.schema.gz





Step 3 : Add a new schema to slapd

  • First, create a configuration file named schema_convert.conf


#vi schema_convert.conf

include /etc/ldap/schema/core.schema

include /etc/ldap/schema/collective.schema

include /etc/ldap/schema/corba.schema

include /etc/ldap/schema/cosine.schema

include /etc/ldap/schema/duaconf.schema

include /etc/ldap/schema/dyngroup.schema

include /etc/ldap/schema/inetorgperson.schema

include /etc/ldap/schema/java.schema

include /etc/ldap/schema/misc.schema

include /etc/ldap/schema/nis.schema

include /etc/ldap/schema/openldap.schema

include /etc/ldap/schema/ppolicy.schema

include /etc/ldap/schema/samba.schema

  • Create a temporary directory to hold the output


# mkdir /tmp/ldif_output

  • Slaptest to convert the schema files:


# slaptest -f schema_convert.conf -F /tmp/ldif_output

  • Edit the generated /tmp/ldif_output/cn=config/cn=schema/cn={12}samba.ldif file, changing the following attributes:


dn: cn=samba,cn=schema,cn=config

...

cn: samba

And remove the following lines from the bottom of the file:

structuralObjectClass: olcSchemaConfig

entryUUID: b53b75ca-083f-102d-9fff-2f64fd123c95

creatorsName: cn=config

createTimestamp: 20080827045234Z

entryCSN: 20080827045234.341425Z#000000#000#000000

modifiersName: cn=config

modifyTimestamp: 20080827045234Z

  • Finally, using the ldapadd utility, add the new schema to the directory


#ldapadd -x -D cn=admin,cn=config -W -f /tmp/ldif_output/cn\=config/cn\=schema/cn\=\{12\}samba.ldif

  • · Copy and paste the following into a file named samba_indexes.ldif


dn: olcDatabase={1}hdb,cn=config

changetype: modify

add: olcDbIndex

olcDbIndex: uidNumber eq

olcDbIndex: gidNumber eq

olcDbIndex: loginShell eq

olcDbIndex: uid eq,pres,sub

olcDbIndex: memberUid eq,pres,sub

olcDbIndex: uniqueMember eq,pres

olcDbIndex: sambaSID eq

olcDbIndex: sambaPrimaryGroupSID eq

olcDbIndex: sambaGroupType eq

olcDbIndex: sambaSIDList eq

olcDbIndex: sambaDomainName eq

olcDbIndex: default sub

  • · Using the ldapmodify utility load the new indexes:


# ldapmodify -x -D cn=admin,cn=config -W -f samba_indexes.ldif

If all went well you should see the new indexes using ldapsearch:

#ldapsearch -xLLL -D cn=admin,cn=config -x -b cn=config -W olcDatabase={1}hdb

Step 4 : Configure smbldap-tools

# cd /usr/share/doc/smbldap-tools/examples/

# cp smbldap_bind.conf /etc/smbldap-tools/

#cp smbldap.conf.gz /etc/smbldap-tools/

#gzip -d /etc/smbldap-tools/smbldap.conf.gz

# net getlocalsid  ( it will give you a id which you have to put in the smbldap.conf file)

#vi smbldap.conf

You need to edit the specific lines according to your individual setup

SID="S-1-5-21-1169339956-3040674750-1689399154"

sambaDomain="OPENLDAP"

slaveLDAP="10.8.0.12"

slavePort="389"

masterLDAP="10.8.0.12"

masterPort="389"

ldapTLS="0"

verify="require"

cafile=""

clientcert=""

clientkey=""

suffix="dc=openldap,dc=server"

usersdn="ou=Users,${suffix}"

computersdn="ou=Computers,${suffix}"

groupsdn="ou=Groups,${suffix}"

idmapdn="ou=Idmap,${suffix}"

sambaUnixIdPooldn="sambaDomainName=OPENLDAP,${suffix}"

scope="sub"

hash_encrypt="SSHA"

crypt_salt_format="%s"

userLoginShell="/bin/bash"

userHome="/home/%U"

userHomeDirectoryMode="700"

userGecos="System User"

defaultUserGid="513"

defaultComputerGid="515"

skeletonDir="/etc/skel"

defaultMaxPasswordAge="45"

userSmbHome=""

userProfile=""

userHomeDrive=""

userScript=""

mailDomain="nextek.in"

with_smbpasswd="0"

smbpasswd="/usr/bin/smbpasswd"

with_slappasswd="0"

slappasswd="/usr/sbin/slappasswd"

Open the file /etc/smbldap-tools/smbldap_bind.conf file for editing

#vi smbldap_bind.conf

Edit the file so the following is correct according to your setup

slaveDN="cn=admin,dc=openldap,dc=server"

slavePw="12345"

masterDN="cn=admin,dc=openldap,dc=server"

masterPw="12345"

Change the permission of smbldap-tools files using below commands.

#chmod 0644 /etc/smbldap-tools/smbldap.conf

#chmod 0600 /etc/smbldap-tools/smbldap_bind.conf

Step 5 : Populate LDAP using smbldap-tools

# smbldap-populate

It will promp for password to assign to user root.

Verify that you have several new entries in your LDAP directory by running the command

# ldapsearch -x -b dc=openldap,dc=server | less

Step 6 : Configure samba server

#cp /etc/samba/smb.conf /etc/samba/smb.conf.org

#vi /etc/samba/smb.conf

Edit the main Samba configuration file /etc/samba/smb.conf commenting the passdb backend option and adding the following(no need to change anything from smb.conf file just put below content in file)

#   passdb backend = tdbsam

# LDAP Settings

passdb backend = ldapsam:ldap://openldap.server

ldap suffix = dc=openldap,dc=server

ldap user suffix = ou=People

ldap group suffix = ou=Groups

ldap machine suffix = ou=Computers

ldap idmap suffix = ou=Idmap

ldap admin dn = cn=admin,dc=openldap,dc=server

ldap ssl = no

ldap passwd sync = yes

add machine script = sudo /usr/sbin/smbldap-useradd -t 0 -w "%u"

#put this content at end of file

[share]

path = /tmp

guest ok = yes

browseable = Yes

writable = yes

Step 7 : Restart samba to enable the new settings

# /etc/init.d/samba restart

Samba needs to know the LDAP admin password

# smbpasswd -w secret

Step 8 :  useradd using smbldap-useradd

# smbldap-useradd -a -m -M test1 -c "test1" test1

-a allows Windows as well as Linux login

-m makes a home directory, leave this off if you do not need local access. PAM will be configured to automatically create a home directory.

-M sets up the username part of their email address

-c specifies their full name

#smbldap-passwd test1

Automount using pam_mount


Step 1 : Install required packages.

#apt-get install libpam-ldap

Above command automatically add the modules in /etc/pam.d/common-* so no need to configure any files.

# cp pam_mount.conf.xml pam_mount.conf.xml.org

# vi pam_mount.conf.xml

<!-- Volume definitions -->

<volume  user="test1"  fstype="smbfs" noroot="1" server="10.8.0.12"  path="share" mountpoint="/home/%(USER)" />

<!-- Volume definitions -->

#reboot

Now login with test1 user and check /home/test1 directory. It will show the /tmp directory data from 10.8.0.12(OpenLDAP server). So we can remotely mount drive using pam_mount module.

sanjay's shared items

My Blog List