Friday, 15 July 2011

how to configure swat server in linux

*
o Articles
+ Case studies
+ Features
+ News
+ NewsVac
+ Reviews
o Documentation
+ What Are Linux HOWTOs?
+ Where Can I Get Linux HOWTOs?
+ HOWTO Translations
+ Categorized List of HOWTOs
+ Single list of HOWTOs
+ Single list of mini-HOWTOs
+ Unmaintained HOWTOs
+ Writing and Submitting a HOWTO
+ Copyright Information
o Distributions
o Forums
o About Us

What is Linux?

Learn about Linux

Download Linux

Get Linux help
Feeds

* Features
* News Feeds
* Forums
* News
* Video
* Answers

Special Offers

Get special offers on:

Linux
Application Dev
Programming
Software

Email:

Feature: System Administration
SWAT your Samba problems
By Federico Kereki on January 31, 2008 (9:00:00 AM)

Share Print Comments

If you need to share files or printers with Windows machines, you're likely using Samba and know how to administer and configure it by editing configuration files and starting and stopping the daemon. However, there's an easier, graphical way to configure your box: the Samba Web Administration Tool.

SWAT allows you to set up all aspects of your Samba server through an intuitive Web interface in a style similar to Webmin. (In fact, if you use Webmin, you can access SWAT by going to Servers -> Samba Windows File Sharing and then clicking on the hammer icon for SWAT.)

Among its interesting features, SWAT includes a wizard that can you help you configure Samba quickly with a basic setup. It also provides context-sensitive help for all parameters (taken directly from the man pages), and it lets you monitor the current state of connections and users. Since it is an integral part of the Samba suite, all available parameters are always up to date.

While SWAT offers convenience, it won't help you learn about Samba. You need to know about Samba before you use SWAT; if you don't know what you're doing, you're likely to do more harm than good.

Good tidings for Samba

Up until last month, you had to do all Samba work without recourse to Windows documentation, because Microsoft didn't share it. This often meant that Linux lagged behind the current SMB implementation, and it was impossible to certify its workings. However, after losing an antitrust lawsuit (and a further appeal) in Europe in September 2007, Microsoft was required to make the SMB protocol available. The Samba creators are now able to make Samba comply 100% with the full protocol, and allow Linux users to have the exact same functions as in Windows users enjoy.
Installation and configuration

SWAT comes with Samba, so unless you're running a really old version of Samba, you will already have it installed. You can check its availability, though, by using the swat --help command. You can also use the following commands to find the program:

# whereis swat swat: /usr/sbin/swat /usr/share/man/man8/swat.8.gz # find / -name swat /etc/webmin/samba/swat /etc/xinetd.d/swat /usr/sbin/swat /usr/share/samba/swat

The /usr/sbin/swat file is the SWAT executable program itself. (I'm using openSUSE 10.3. In other distributions you might find SWAT somewhere else.) You will have the (root access only) /etc/webmin/samba/swat file only if you have Webmin installed; this is where Webmin keeps your Samba user and password. Finally, you must edit /etc/xinetd.d/swat so that SWAT will be available through xinetd. Working as root, edit it so it looks like this:

# SWAT is the Samba Web Administration Tool. service swat { port = 901 groups = yes socket_type = stream protocol = tcp wait = no user = root server = /usr/sbin/swat only_from = 127.0.0.1 log_on_failure += USERID disable = no }

Note that in the server line, I put the path I found earlier with whereis or find. It's likely that the last line will read disable=yes because many distributions don't enable SWAT by default. My version of this file was missing the port and groups lines, so I had to add them. When you're done editing the file, run /etc/init.d/xinetd restart, and SWAT will be ready to work.

Note: On older systems, you might have inetd instead of xinetd; in that case, look for /etc/inetd.conf, which should include an entry like this:

# swat is the Samba Web Administration Tool swat stream tcp nowait.400 root /usr/sbin/swat swat

Use /etc/init.d/inetd restart to activate your edits.
Using SWAT

[Figure 1: Click to enlarge] Figure 1: Click to enlarge SWAT works by rewriting the configuration files at /etc/samba/smb.conf and restarting Samba as needed. Note, however, that when it rewrites the file, it wipes away all comments, so if you're the kind of sysadmin who likes to include documentation within configuration files, you'll have a reason to hate SWAT. Unsupported parameters are deleted, parameters that have the default value are ignored, and SWAT changes the order of the parameters, so your carefully handcrafted configuration file may look rather bleak after SWAT is done with it.

Access SWAT by opening a browser and going to http://127.0.0.1:901. The home page provides access to the man documentation pages and some extra Samba documentation, including some complete books. You'll have to install the samba-doc additional package to get the latter.

Here's a list of SWAT's other pages and the functions you can use:

* Globals: Provides access to the global parameters (what else?) in smb.conf. You can work at one of two levels: Basic, which shows only the more important options listed, or Advanced, which shows every available parameter. Click on the corresponding buttons to pick your desired level. You can click on the Help links to get specific help about each parameter. After making any edits, click on Commit Changes to save your choices, or Reset Values to go back to the original smb.conf values.
* Shares: Lets you create, edit, or drop shares. To edit an existing share, pick it from the combo box, then click on Choose Share; clicking on Delete Share will delete it. When you add or edit a share, you can specify several parameters on either Basic or Advanced levels, such as name, path, valid and invalid users, and read-only or writable. Remember to click on Commit Changes (or Reset Values) before changing pages or your work will have been in vain.
* Printers: Similar to Shares, but works with printers instead.
* Wizard: Lets you do a quick server configuration. You can pick either a standalone server, a domain controller, or a domain member. You must also specify how the server will work with Windows Internet Name Service (WINS) and whether you want to expose your home directories. Click on "Rewrite smb.conf" or on Commit to save your values, and you will have a basic Samba server running, which you can then further tweak using the other options.
* Status: Shows you which services are running: usually smbd (the Samba daemon itself) and nmbd (the NetBIOS nameserver support daemon), and possibly Winbind (to allow a Linux box to become a Windows domain member). You also get the listing of all active connections (which you may kill, if you need to), active shares, and open files. You can click on Auto Refresh so the page will refresh on its own every so many seconds (30 by default).
* View: Lets you view the current configuration file. You can click on the View button to see it either in the normal view (minimalist, with only the nondefault attributes) or the full view (with all possible parameters).
* Password: Allows you to create, delete, enable, or disable local Samba users and change passwords for a local or remote server.

Conclusion

Whether you're just starting out with Samba or are an experimented sysadmin, SWAT can you help you configure your box more easily through its graphical interface.
Federico Kereki is an Uruguayan systems engineer with more than 20 years' experience developing systems, doing consulting work, and teaching at universities.

Sunday, 5 June 2011

An A-Z of the Bash command line for linux

adduser Add a user to the system
addgroup Add a group to the system
alias Create an alias •
apropos Search Help manual pages (man -k)
apt-get Search for and install software packages (Debian/Ubuntu)
aptitude Search for and install software packages (Debian/Ubuntu)
aspell Spell Checker
awk Find and Replace text, database sort/validate/index
b
basename Strip directory and suffix from filenames
bash GNU Bourne-Again SHell
bc Arbitrary precision calculator language
bg Send to background
break Exit from a loop •
builtin Run a shell builtin
bzip2 Compress or decompress named file(s)
c
cal Display a calendar
case Conditionally perform a command
cat Concatenate and print (display) the contents of file(s)
cd Change Directory
cfdisk Partition table manipulator for Linux
chgrp Change group ownership
chmod Change access permissions
chown Change file owner and group
chroot Run a command with a different root directory
chkconfig System services (runlevel)
cksum Print CRC checksum and byte counts
clear Clear terminal screen
cmp Compare two files
comm Compare two sorted files line by line
command Run a command - ignoring shell functions •
continue Resume the next iteration of a loop •
cp Copy one or more files to another location
cron Daemon to execute scheduled commands
crontab Schedule a command to run at a later time
csplit Split a file into context-determined pieces
cut Divide a file into several parts
d
date Display or change the date & time
dc Desk Calculator
dd Convert and copy a file, write disk headers, boot records
ddrescue Data recovery tool
declare Declare variables and give them attributes •
df Display free disk space
diff Display the differences between two files
diff3 Show differences among three files
dig DNS lookup
dir Briefly list directory contents
dircolors Colour setup for `ls'
dirname Convert a full pathname to just a path
dirs Display list of remembered directories
dmesg Print kernel & driver messages
du Estimate file space usage
e
echo Display message on screen •
egrep Search file(s) for lines that match an extended expression
eject Eject removable media
enable Enable and disable builtin shell commands •
env Environment variables
ethtool Ethernet card settings
eval Evaluate several commands/arguments
exec Execute a command
exit Exit the shell
expect Automate arbitrary applications accessed over a terminal
expand Convert tabs to spaces
export Set an environment variable
expr Evaluate expressions
f
false Do nothing, unsuccessfully
fdformat Low-level format a floppy disk
fdisk Partition table manipulator for Linux
fg Send job to foreground
fgrep Search file(s) for lines that match a fixed string
file Determine file type
find Search for files that meet a desired criteria
fmt Reformat paragraph text
fold Wrap text to fit a specified width.
for Expand words, and execute commands
format Format disks or tapes
free Display memory usage
fsck File system consistency check and repair
ftp File Transfer Protocol
function Define Function Macros
fuser Identify/kill the process that is accessing a file
g
gawk Find and Replace text within file(s)
getopts Parse positional parameters
grep Search file(s) for lines that match a given pattern
groups Print group names a user is in
gzip Compress or decompress named file(s)
h
hash Remember the full pathname of a name argument
head Output the first part of file(s)
help Display help for a built-in command •
history Command History
hostname Print or set system name
i
iconv Convert the character set of a file
id Print user and group id's
if Conditionally perform a command
ifconfig Configure a network interface
ifdown Stop a network interface
ifup Start a network interface up
import Capture an X server screen and save the image to file
install Copy files and set attributes
j
jobs List active jobs •
join Join lines on a common field
k
kill Stop a process from running
killall Kill processes by name
l
less Display output one screen at a time
let Perform arithmetic on shell variables •
ln Make links between files
local Create variables •
locate Find files
logname Print current login name
logout Exit a login shell •
look Display lines beginning with a given string
lpc Line printer control program
lpr Off line print
lprint Print a file
lprintd Abort a print job
lprintq List the print queue
lprm Remove jobs from the print queue
ls List information about file(s)
lsof List open files
m
make Recompile a group of programs
man Help manual
mkdir Create new folder(s)
mkfifo Make FIFOs (named pipes)
mkisofs Create an hybrid ISO9660/JOLIET/HFS filesystem
mknod Make block or character special files
more Display output one screen at a time
mount Mount a file system
mtools Manipulate MS-DOS files
mtr Network diagnostics (traceroute/ping)
mv Move or rename files or directories
mmv Mass Move and rename (files)
n
netstat Networking information
nice Set the priority of a command or job
nl Number lines and write files
nohup Run a command immune to hangups
notify-send Send desktop notifications
nslookup Query Internet name servers interactively
o
open Open a file in its default application
op Operator access
p
passwd Modify a user password
paste Merge lines of files
pathchk Check file name portability
ping Test a network connection
pkill Stop processes from running
popd Restore the previous value of the current directory
pr Prepare files for printing
printcap Printer capability database
printenv Print environment variables
printf Format and print data •
ps Process status
pushd Save and then change the current directory
pwd Print Working Directory
q
quota Display disk usage and limits
quotacheck Scan a file system for disk usage
quotactl Set disk quotas
r
ram ram disk device
rcp Copy files between two machines
read Read a line from standard input •
readarray Read from stdin into an array variable •
readonly Mark variables/functions as readonly
reboot Reboot the system
rename Rename files
renice Alter priority of running processes
remsync Synchronize remote files via email
return Exit a shell function
rev Reverse lines of a file
rm Remove files
rmdir Remove folder(s)
rsync Remote file copy (Synchronize file trees)
s
screen Multiplex terminal, run remote shells via ssh
scp Secure copy (remote file copy)
sdiff Merge two files interactively
sed Stream Editor
select Accept keyboard input
seq Print numeric sequences
set Manipulate shell variables and functions
sftp Secure File Transfer Program
shift Shift positional parameters
shopt Shell Options
shutdown Shutdown or restart linux
sleep Delay for a specified time
slocate Find files
sort Sort text files
source Run commands from a file `.'
split Split a file into fixed-size pieces
ssh Secure Shell client (remote login program)
strace Trace system calls and signals
su Substitute user identity
sudo Execute a command as another user
sum Print a checksum for a file
suspend Suspend execution of this shell •
symlink Make a new name for a file
sync Synchronize data on disk with memory
t
tail Output the last part of files
tar Tape ARchiver
tee Redirect output to multiple files
test Evaluate a conditional expression
time Measure Program running time
times User and system times
touch Change file timestamps
top List processes running on the system
traceroute Trace Route to Host
trap Run a command when a signal is set(bourne)
tr Translate, squeeze, and/or delete characters
true Do nothing, successfully
tsort Topological sort
tty Print filename of terminal on stdin
type Describe a command •
u
ulimit Limit user resources •
umask Users file creation mask
umount Unmount a device
unalias Remove an alias •
uname Print system information
unexpand Convert spaces to tabs
uniq Uniquify files
units Convert units from one scale to another
unset Remove variable or function names
unshar Unpack shell archive scripts
until Execute commands (until error)
useradd Create new user account
usermod Modify user account
users List users currently logged in
uuencode Encode a binary file
uudecode Decode a file created by uuencode
v
v Verbosely list directory contents (`ls -l -b')
vdir Verbosely list directory contents (`ls -l -b')
vi Text Editor
vmstat Report virtual memory statistics
w
watch Execute/display a program periodically
wc Print byte, word, and line counts
whereis Search the user's $path, man pages and source files for a program
which Search the user's $path for a program file
while Execute commands
who Print all usernames currently logged in
whoami Print the current user id and name (`id -un')
Wget Retrieve web pages or files via HTTP, HTTPS or FTP
write Send a message to another user
x
xargs Execute utility, passing constructed argument list(s)
xdg-open Open a file or URL in the user's preferred application.
yes Print a string until interrupted
. Run a command script in the current shell
### Comment / Remark

Saturday, 4 June 2011

Install SWAT to configure Samba from Web browser.

Install SWAT
2010/11/05
Install SWAT to configure Samba from Web browser.

[1] Install xinetd first because it's needed.
[root@lan03 ~]#
yum -y install xinetd samba-swat


[root@lan03 ~]#
vi /etc/xinetd.d/swat


# line 10: add IP address you permit

only_from = 127.0.0.1
10.0.0.0/24


# line 14: change

disable =
no


[root@lan03 ~]#
/etc/rc.d/init.d/xinetd start

Starting xinetd:
[ OK ]

[root@lan03 ~]#
chkconfig xinetd on
[2] Access to [http://(server's hostname or IP address):901]. After accessing, user name and password is required to login. Input for root's one in it and login, then following screen is shown and you can configure samba on browser.

Friday, 3 June 2011

Block Downloading in squid Server

MP3, mpg, mpeg, exec files

by Vivek Gite on January 6, 2007 · 64 comments
Q. For security and to save bandwidth I would like to configure Squid proxy server such way that I do not want my users to download all of the following files:
MP3
MPEG
MPG
AVG
AVI
EXE
How do I configure squid content filtering?
A. You can use squid ACL (access control list) to block all these files easily.

How do I block music files using squid content filtering ACL?

First open squid.conf file /etc/squid/squid.conf:
# vi /etc/squid/squid.conf
Now add following lines to your squid ACL section:
acl blockfiles urlpath_regex "/etc/squid/blocks.files.acl"
You want display custom error message when a file is blocked:
# Deny all blocked extension
deny_info ERR_BLOCKED_FILES blockfiles
http_access deny blockfiles

Save and close the file.
Create custom error message HTML file called ERR_BLOCKED_FILES in /etc/squid/error/ directory or /usr/share/squid/errors/English directory.
# vi ERR_BLOCKED_FILES
Append following content:
<HTML>
<HEAD>
<TITLE>ERROR: Blocked file content</TITLE>
</HEAD>
<BODY>
<H1>File is blocked due to new IT policy</H1>
<p>Please contact helpdesk for more information:</p>
Phone: 555-12435 (ext 44)<br>
Email: helpdesk@yourcorp.com<br>
Caution: Do not include HTML close tags </HTML> </BODY> as it will be closed by squid.
Now create /etc/squid/blocks.files.acl file:
# vi /etc/squid/blocks.files.acl
Append following text:
\.[Ee][Xx][Ee]$
\.[Aa][Vv][Ii]$
\.[Mm][Pp][Gg]$
\.[Mm][Pp][Ee][Gg]$
\.[Mm][Pp]3$

Save and close the file. Restart Squid:
# /etc/init.d/squid restart
Squid in action:


Squid content filtering howto

Downlaod Ubuntu

Download fedora 15 Desktop ISO