Linux setup shared directory
Sharing a directory among users in same group is one of the essential tasks. You need to use chmod command and add user to appropriate group. To make idea clear here is an scenario: /home/myproj : is shared directory usr1, usr2, ... usrN : would like to work and share files in /home/myproj directory padmin : Main project administrator user Step # 1: Create a shared directory /home/myproj If this directory does not exist then create it: # mkdir /home/myproj Step # 2: Create the group shared group You need to create a new group. Let us assume group name is myproj # groupadd myproj Step # 3: Add user project administrator (padmin) and setup password: # useradd -d /home/myproj/ -g myproj -m padmin # passwd padmin Step #4: Add rest of users to group myproj # useradd -d /home/myproj/ -g myproj usr1 # passwd usr1 Add second user: # useradd -d /home/myproj/ -g myproj usr2 # passwd usr2 ... and so on... Step #5: Setup permission on /home/myproj directory as follows: (a) Setup group ownership to myproj group: # chown -R padmin.myproj /home/myproj/ (b) Setup full permission for group and owner on a directory: # chmod -R 775 /home/myproj/ (c) Setup sgid bit. So what is sgid bit? Normally whenever you creates file in a directory it belong to default group of user. When a file is created in a directory with the sgid bit set it belogns to the same group as the directory. The result is all users of myproj group can create/alter files in /home/myproj directory: # chmod -R 2775 /home/myproj/ OR # chmod -R g+s /home/myproj/
Table Of Contents
See also: FreeBSD : How to setup shared directories [1]
How do I find out what network services are running or listing under Linux?
Q. How do I find out what network service are running under Linux operating system? A. For security reason it is necessary to find out what services are running. With the help of netstat command, you can print information about the Linux networking subsystem including running services. It can display program name and PID for each socket belongs to. Use netstat as follows:
$ netstat -atup OR $ netstat -atup | grep LISTEN Where, -t : Select all TCP services -u : Select all UDP services -a : Display all listening and non-listening sockets. -p : Display the PID and name of the program to which each socket belongs
How do I run X windows program as normal user?
Microsoft windows XP has runas command which allows a user to run specific tools and programs with different permissions than the user's current logon provides. Linux and other UNIX like operating system provides the su or sudo command for same purpose. However, su/sudo command is not so useful when it comes to X program. For example when you logged in as a normal user, you need to run an X window application as root. If I run application as follows: $ su Password # xeyes It will bump you back with an error: (program:15082): Gtk-WARNING **: cannot open display: OR ** WARNING ** cannot open display However both KDE and Gnome come with tools to deal with this problem. Method # 1: If you are using KDE then use following command at shell prompt: kdesu command-name $ kdesu xeyes Method # 2: If you are using Gnome then use following command at shell prompt: $ gksuexec Or use GUI itself, click on Applications > System tools > Select Run as different user
Create runas alias as follows: $ alias runas='su -c $@' Add above alias to your bash startup script
[1]Method # 3:
$ echo "alias runas='su -c $@'" >> .bash_profile
Table Of Contents
You can now use alias as follows to start any x program $ runas program-name $ runas xeyes Method # 4: The old way The problem is with two environment variable DISPLAY and XAUTHORITY. You need to setup them correctly to run X windows program as a root user while logged in as a normal user. So how do you fix this problem? Simply set these two variables to point to current logged in users environment variable. Let us assume you are currently login as vivek user. Step # 1 Become super-use vivek@debian:~$ su debian:~# Step # 2 Setup variables # export DISPLAY=0:0 # export XAUTHORITY=/home/vivek/.Xauthority Step # 3 Execute X program as a root user # xeyes
How do I find the url for my cgi-bin?
The CGI is acronym for Common Gateway Interface. It is a standard for interfacing external applications with Apache Web servers. A CGI program is executed in real-time, so that it can output dynamic information. It can be written in Perl, Php, Bash, C/C++ or other programming languages. But how do I find the url for my cgi-bin? It's not in my /var/www/ directory. Apache web server use ScriptAlias directive defines cgi-bin directory that contain server scripts. You can use open Apache web server configuration file using text editor such as vi and look for ScriptAlias directive: httpd.conf file location: Debian Linux: $ vi /etc/apache-perl/httpd.conf Red Hat/ Fedora Core Linux: $ vi /etc/httpd/conf/httpd.conf
FreeBSD: $ vi /usr/local/etc/httpd.conf
You can also use grep command as follows to find out your cgi-bin directory: $ grep 'ScriptAlias' /etc/httpd/conf/httpd.conf
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ /usr/lib/cgi-bin/ is cgi-bin directory. If you have public_htm directory then cgi-bin directory should be inside this directory. Once you located cgi-bin directory you can use it. Default cgi-bin directory locations: Red Hat Linux: /var/www/cgi-bin/ Fedora Linux: /var/www/cgi-bin/ Debian Linux: /usr/lib/cgi-bin/ FreeBSD: /usr/local/www/cgi-bin/ Finally your url location depends upon directory location. You can use http://ip-address/cgi-bin or http://ipaddress/~yourname/cgi-bin (replace ip-address with your domain name)
How do I find what dependencies a rpm file has?
RPM is a Package Manager for popular distribution such as Red Hat, Suse and many others. It is a powerful command line package management system for installing uninstalling, verifying, querying, and updating Linux computer software packages. You can finding out what dependencies a rpm file has i.e. it will tell you what you need to install package with following command: rpm -qpR {.rpm-file} rpm -qR {package-name} Find out what dependencies a uninstalled rpm file called mediawiki-1.4rc1-4.i586.rpm: # rpm -qpR mediawiki-1.4rc1-4.i586.rpm It will print list of dependencies on screen (output): mod_php php-session php-gettext php-zlib php-mysql ImageMagick-Magick++ tetex cjk-latex rpmlib(PayloadFilesHavePrefix) However RPM has in build mechanism to tell you about dependencies. Just try to install package and it will give you list of dependencies. # rpm -ivh mediawiki-1.4rc1-4.i586.rpm Output: error: Failed dependencies: mod_php is needed by mediawiki-1.4rc1-4 php-session is needed by mediawiki-1.4rc1-4 php-gettext is needed by mediawiki-1.4rc1-4 php-zlib is needed by mediawiki-1.4rc1-4 php-mysql is needed by mediawiki-1.4rc1-4 ImageMagick-Magick++ is needed by mediawiki-1.4rc1-4 tetex is needed by mediawiki-1.4rc1-4 cjk-latex is needed by mediawiki-1.4rc1-4 Note: .rpm file: File with .RPM extension. Typically this file is not installed. It may be on CD or you just downloaded from Internet. package-name: It is installed RPM file. You can solve dependencies problem by installing each individual package(s). If you are using Red hat Linux then you can try this tip [1]. If you are using Fedora core Linux then try yum [2]. If you are using Suse linux then use Yast to install rpms.