How do I list file stored inside a rpm file?
Q. How do I install flash on 64 bit Linux desktop operating system?
I need to disable firewall in Linux for testing purpose. I’m using CentOS and RHEL version 4.4 / 5 / 6. How do I disable the firewall in Linux?
Q. I am new to Linux but not to c programming. At university we are using Turbo C compiler under DOS/Windows XP to write and compile C programs. Under Linux Iâ€™ve small program called test.c. How do I compile and see the output of C program in Linux? Note Iâ€™m using Fedora Core Linux.
A. Under Linux you need to gcc (GNU project C and C++ compiler) command to compile a program. When you compile a program it generates an executable file called a.out.
gcc -o output-file program.c
Task: Compile program
To compile type the command:
$ gcc test.c
Task: Execute program to see output
Above command will create a file called a.out. To see output of test.c program type:
Task: Compile to specific executable file
You can specify an execuable file name while compiling program itself:
$ gcc -o test test.c
Now execute test (see output of test.c)
Q. How do I configure xinetd under Fedora Core Linux?
A. xinetd, the eXtended InterNET Daemon, is an open-source daemon which runs on many Linux and Unix systems and manages Internet-based connectivity. It offers a more secure extension to or version of inetd, the Internet daemon.
xinetd performs the same function as inetd: it starts programs that provide Internet services. Instead of having such servers started at system initialization time, and be dormant until a connection request arrives, xinetd is he only daemon process started and it listens on all service ports for the services listed in its configuration file. When a request comes in, xinetd starts the appropriate server. Because of the way it operates, xinetd (as well as inetd) is also referred to as a super-server.
Task: xinetd Configuration files location
Following are important configuration files for xinetd:
- /etc/xinetd.conf – The global xinetd configuration file.
- /etc/xinetd.d/ directory – The directory containing all service-specific files such as ftp
Task: Understanding default configuration file
You can view default configuration file with less or cat command:
# less /etc/xinetd.confOR
# cat /etc/xinetd.confOutput:
# Simple configuration file for xinetd
# Some defaults, and include /etc/xinetd.d/
instances = 60
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
- instances = 60 : Determines the number of servers that can be simultaneously active for a service. So 60 is the maximum number of requests xinetd can handle at once.
- log_type = SYSLOG authpriv: Determines where the service log output is sent. You can send it to SYSLOG at the specified facility (authpriv will send log to /var/log/secure file).
- log_on_success = HOST PID: Force xinetd to log if the connection is successful. It will log HOST name and Process ID to /var/log/secure file.
- log_on_failure = HOST: Force xinetd to log if there is a connection dropped or if the connection is not allowed to /var/log/secure file
- cps = 25 30: Limits the rate of incoming connections. Takes two arguments. The first argument is the number of connections per second to handle. If the rate of incoming connections is higher than this, the service will be temporarily disabled. The second argument is the number of seconds to wait efore re-enabling the service after it has been disabled. The default for this setting is 50 incoming connections and the interval is 10 seconds. This is good to avoid DOS attack against your service.
- includedir /etc/xinetd.d: Read other service specific configuration file this directory.
Task: How to create my own service called foo
Here is sample config file for service called foo located at /etc/xinetd.d/foo
# vi /etc/xinetd.d/foo
And append following text:
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/sbin/foo
instances = 20
- socket_type: Sets the network socket type to stream.
- protocol: Sets the protocol type to TCP
- wait: You can set the value to yes or no only. It Defines whether the service is single-threaded (if set to yes) or multi-threaded (if set to no).
- user: User who will run foo server
Task: Stop or restart xinetd
To restart xinetd service type the command:
# /etc/init.d/xinetd restart
To stop xinetd service type the command:
# /etc/init.d/xinetd stop
To stop xinetd service type the command:
# /etc/init.d/xinetd start
Task: Verify that xinetd is running
Type the following command to verify xinetd service is running or NOT:
# /etc/init.d/xinetd statusOutput:
xinetd (pid 6059) is running...
- Read man pages of xinetd.conf and xinetd for more information.
Q. I have a compact flash card reader hardware device connected to USB port of computer system. Now how do I mount and access a compact flash card connected to this Linux system (Fedora Core)?
A. Your compact flash card will automatically detected by Linux. First create a mount point (type the following command as root user):
# mkdir -p /mnt/cflashcard
If you don’t have any SCSI device, your first partition on a compact flash card should be /dev/sda1 (second will be /dev/sda2 and so on). If you have 1 SCSI device attached, your first partition on a compact flash card should be /dev/sdb1.
Mount partition using mount command:
# mount /dev/sda1 /mnt/cflashcard
To see or access files:
# cd /mnt/cflashcard
# ls -l
Open /etc/fstab file:
# vi /etc/fstab
Add an entry (append) to /etc/fstab file:
/dev/sda1 /mnt/cflashcard auto user,rw,exec 0 0
Save and close the file.
How do I unmount or unplug card?
First unmount card with umount command and then unplug card:
# umount /mnt/flash