What does a shell script look likeI in Linux?
Something like this:
#!/bin/sh
### BEGIN INIT INFO
# Provides: mpd
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: autofs $network $named alsa-utils pulseaudio
# Should-Stop: autofs $network $named alsa-utils pulseaudio
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Music Player Daemon
# Description: Start the Music Player Daemon (MPD) service
# for network access to the local audio queue.
### END INIT INFO
. /lib/lsb/init-functions
PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=mpd
DESC="Music Player Daemon"
DAEMON=/usr/bin/mpd
MPDCONF=/etc/mpd.conf
START_MPD=true
# Exit if the package is not installed
[ -x "$DAEMON" ] exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
if [ -n "$MPD_DEBUG" ]; then
set -x
MPD_OPTS=--verbose
fi
DBFILE=$(sed -n 's/^[[:space:]]*db_file[[:space:]]*"\?\([^"]*\)"\?/\1/p' $MPDCONF)
PIDFILE=$(sed -n 's/^[[:space:]]*pid_file[[:space:]]*"\?\([^"]*\)"\?/\1/p' $MPDCONF)
mpd_start () {
if [ "$START_MPD" != "true" ]; then
log_action_msg "Not starting MPD: disabled by /etc/default/$NAME".
exit 0
fi
log_daemon_msg "Starting $DESC" "$NAME"
if [ -z "$PIDFILE" -o -z "$DBFILE" ]; then
log_failure_msg \
"$MPDCONF must have db_file and pid_file set; cannot start daemon."
exit 1
fi
PIDDIR=$(dirname "$PIDFILE")
if [ ! -d "$PIDDIR" ]; then
mkdir -m 0755 $PIDDIR
if dpkg-statoverride --list --quiet /run/mpd > /dev/null; then
# if dpkg-statoverride is used update it with permissions there
dpkg-statoverride --force --quiet --update --add $( dpkg-statoverride --list --quiet /run/mpd ) 2> /dev/null
else
# use defaults
chown mpd:audio $PIDDIR
fi
fi
start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" \
--exec "$DAEMON" -- $MPD_OPTS "$MPDCONF"
log_end_msg $?
}
mpd_stop () {
if [ -z "$PIDFILE" ]; then
log_failure_msg \
"$MPDCONF must have pid_file set; cannot stop daemon."
exit 1
fi
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --quiet --oknodo --retry 5 --pidfile "$PIDFILE" \
--exec $DAEMON
log_end_msg $?
}
# note to self: don't call the non-standard args for this in
# {post,pre}{inst,rm} scripts since users are not forced to upgrade
# /etc/init.d/mpd when mpd is updated
case "$1" in
start)
mpd_start
;;
stop)
mpd_stop
;;
status)
status_of_proc -p $PIDFILE $DAEMON $NAME
;;
restart|force-reload)
mpd_stop
mpd_start
;;
force-start)
mpd_start
;;
force-restart)
mpd_stop
mpd_start
;;
force-reload)
mpd_stop
mpd_start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}"
exit 2
;;
esac
What does the sudo command do in linux?
When u put sudo before a command in terminal the command run with root privileges
How do you start or stop a service in redhat Linux?
after you have identified the service run the command
# service (service name) stop
#service (service name) start
What command can be used in the Linux system to determine the current configuration of the system?
There are multiple commands which allow a user or administrator to either view or change the system configuration, though most such changes must be made by the root user (uid0) or equivalent.
To view the networking configuration for instance, you may issue the command:
# ifconfig -a
To view the routing table, you could issue the command:
# netstat -r
To view the current network connections you could issue the command:
# netstat -a (though you'll likely want to pipe the output into the less command)
To view the current process table you could issue the command:
# ps -afe
All of the above commands have many, many switches not mentioned in this response and this response is necessarily incomplete. For more information on the above commands, consult your system's man pages...
$ man netstat
or
$ man ifconfig
etc...
or consider acquiring one or more of the books published by Tim O'Reilly. I have dozens of them. [JMH]
What does is command do in Linux?
A command is an instruction from a user to get the computer to do something! A simple example: open a terminal and type the command "man man" (without the quotes) and the result will be the manual page of the man command.
Note: The command ls stands for list the files in the current directory.
Why Linux operating system used in government sectors?
Linux and Free, Open Source Software in general use open protocols and standards, meaning that data created using this software is not locked into one particular vendor, thus avoiding data loss through lack of support for a proprietary format and thus making it very attractive in government sectors.
What does the term heirarchical mean in reference to the Linux file system?
The Filesystem Hierarchy Standard (FHS) defines the main directories and their contents in Linux operating systems
What type of software is used in Linux operating system?
Linux is not an operating system but a kernel. Operating systems that are referred to as "Linux distributions" have a lot of common software, including mainly the Linux kernel, the GNU software and for most a graphical user interface (GUI) based on the X Window System.
The other software of the basic desktop environment (like office-software, web browser, file manager, PDF viewer, music player or audio player to randomly name a few) is mostly bundled and depends on the choice of desktop environment (like gnome, KDE, XFCE, LXDE to name the most widely used ones).
If the question is, which software will run on "Linux distributions", it is way to much to know it all.
If the question is rather, which software will NOT run on "Linux distributions" as opposed to the latest Windows or MacOS, this includes some software that is taylored for these systems (like the latest versions of MS Office, Windows Media Player, Internet Explorer, Safari etc.) and many new programs sold for profit including recent games. The reason for the latter is the small number of "Linux" users in comparison to Windows users, which makes it most profitable for software vendors to primarily aim for the Windows market.
Change user permission on a command line?
This is dependent on what kind of "permissions" you mean.
Changing ownership of a file is through chown.
Changing how people can access a file is through chmod.
Changing what groups the user is in is usually through gpasswd.
If you mean "make a user an administrator" then they'll either need to be included in the sudoers file (USE VISUDO.) or, if sudo is not installed, the user will need to know root's password, which is DANGEROUS, to use su or login as root.
Is Linux a robust operating system that is good training tool for unix?
No, Linux IS Unix, so the question makes no sense. Unix is a general term for a class of operating systems. Linux is also a term applied to more than one operating system variant, but all Linux OS are Unix OS. Redhat is one type of Linux. BSD is a type of Unix that is not Linux.
The word kernel comes from an onion.
Where the innermost part of the onion is called a kernel.
Similar analogy is applied here. The innermost crucial part of an operating system is called as the kernel, while the shell(bash) is the part which covers the kernel so as to hide its complexities.
What is process id of Linux kernel?
The Linux kernel does not have a process id (also called pid). Process 1 is almost always the process scheduler, init. PIDs are assigned to each subsequent process that is started and they will usually vary. Do not remove init, doing so would likely have catastrophic consequences, a kernel panic for instance.
Unless you particularly enjoy using the crash utility.
$ man crash
[JMH]
What is sem post and sem wait functions?
The sem_wait() function locks the semaphore referenced by sem by performing a semaphore lock operation on that semaphore. If the semaphore value is currently zero, then the calling thread will not return from the call to sem_wait()until it either locks the semaphore or the call is interrupted by a signal.
Upon successful return, the state of the semaphore is locked and remains locked until the sem_post() function is executed and returns successfully. The sem_wait() function is interruptible by the delivery of a signal.
The sem_post() function unlocks the semaphore referenced by sem by performing a semaphore unlock operation on that semaphore.
If the semaphore value resulting from this operation is positive, then no threads were blocked waiting for the semaphore to become unlocked; the semaphore value is simply incremented.
If the value of the semaphore resulting from this operation is zero, then one of the threads blocked waiting for the semaphore will be allowed to return successfully from its call to sem_wait(). If the symbol _POSIX_PRIORITY_SCHEDULING is defined, the thread to be unblocked will be chosen in a manner appropriate to the scheduling policies and parameters in effect for the blocked threads. In the case of the schedulers SCHED_FIFO and SCHED_RR, the highest priority waiting thread will be unblocked, and if there is more than one highest priority thread blocked waiting for the semaphore, then the highest priority thread that has been waiting the longest will be unblocked. If the symbol _POSIX_PRIORITY_SCHEDULING is not defined, the choice of a thread to unblock is unspecified.
The sem_post() interface is reentrant with respect to signals and may be invoked from a signal-catching function.
The same thing as networking in Windows or OS X: The system by which Linux will be able to communicate with other computers.
How do you change the executable bit in Linux for a .exe file?
chmod +x is the command to set the executable flag in Linux but, Linux does not use exe files.
Who is created with inventing the Linux Kernel?
The LUnix kernel and most of the userland was written by Daniel Dollman.
Can you resize the linux-swap partition on the fly linux mint?
You can by using gparted. At a terminal prompt type sudo gparted and your partitions will be shown, from where alterations can be made. You need to use sudo gparted to become superuser. If gparted is not installed, the terminal will say so and tell you how to install gparted. Warning: back up important files first to an external flash or hard-drive in case things go wrong. And have an upto date operating system on a CD or DVD to reinstall the OS should things go seriously wrong (just in case!).
Further warning: GParted can't usually do anything at all to a partition if it is in use. This is why there are GParted live media.
How do you restore the deleted file from unix machine Sun Solaris?
Since there is no undelete or "trash" in Solaris (unless you are using a GUI interface) you have to restore it from a backup media.
What is the pwd command in Linux?
The pwd command prints the working directory. The working directory is the directory you are "in", where operations on files that don't have an absolute path specified will be performed. For instance, if my working directory is /home/username/stuff, then the command echo "test" > test.txt would place the file test.txt in that directory.
Why is TCP faster in Linux than in Windows?
Pretty much everything is faster in Linux than in Windows. The Windows programmers need to prove to their bosses that they are doing the right thing, but the Linux programmers only need to prove to their peers that they are doing the right thing when they make improvements. Linux has things like zero-copy networking, which are not widely implemented in the Windows kernel(s).