Trouble running statrup script on Linux [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I'm using the Amazon flavor of Linux
uname -a
Linux mydomain.org 3.19.25-82.99.amzn1.x86_64 #1 SMP Wed Dec 3 21:29:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
and I want to run the following script upon system reboot ...
ls -al /home/davea/install/apache-tomcat-6.0.35/bin/startup.sh
-rwxr-xr-x 1 davea mycompany 2023 Nov 28 2011 /home/davea/install/apache-tomcat-6.0.35/bin/startup.sh
So I created this file,
-rwxr-xr-x 1 root root 73 Dec 10 19:29 /etc/init.d/start_tomcat
with the lines
#!/bin/sh
sh /home/davea/install/apache-tomcat-6.0.35/bin/startup.sh
However, when I reboot my system, this script isn't getting invoked. What steps have I left out? I can run the script fine at a command line when I'm logged in.
Edit: Also, I created this symlink in /etc/rc.d ...
ls -al /etc/rc.d/start_tomcat
lrwxrwxrwx 1 root root 24 Dec 10 19:29 /etc/rc.d/start_tomcat -> /etc/init.d/start_tomcat
Still no luck.

You have to add the start-up script under init.d to your default runlevel.
sudo update-rc.d /etc/init.d/start_tomcat defaults
Which should create symlinks to your script under the appropriate /etc/rc?.d folder(s).

This depends on which startup program is being used. Assuming you have privileges to do so, and if the star up program is the chkconfig program your etc/init.d/start script must follow suit in that you need such header fields like:
# chkconfig: <levels> <start> <stop>
# description: <some description>
For other programs, like systemctl (redhat/fedora) you'll need to create a file with directives in it in the following folder:
/etc/systemd/system/
You'd typically make a file called serviceName.service with the following entries:
[Unit]
Description=MyApp
[Service]
ExecStart=/path/to/myService/executable.sh
[Install]
WantedBy=multi-user.target
Then run:
sudo systemctl enable /etc/systemd/system/hello.service
sudo systemctl start hello.service
If this is a LSB (Linux Standards Based) OS/Startup you should follow the tutorial below:
https://wiki.debian.org/LSBInitScripts

Related

Why does one command need sudo but the other one doesn't with the same permissions [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 days ago.
Improve this question
I have the bzcat command with the following permissions:
-rwxr-xr-x 3 root root 39144 Sep 5 2019 /bin/bzcat
I have the bzmore command with the following permissions:
-rwxr-xr-x 1 root root 1297 Sep 5 2019 /bin/bzmore
And I have a bz2 zip file:
-r-------- 1 root root 61 Feb 17 14:37 flag.bz2
When I use bzmore flag.bz2 it works fine. But when I use bzcat flag.bz2 I get Can't open input file flag.bz2: Permission denied.. Why is this? If I put sudo in front of bzcat it works fine too but why doesn't bzmore need this when they both have the same permissions.
I tried running all the commands to test out what happened.

difference between /bin/ls and /usr/bin/ls [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
It seems that both /bin/ls and /usr/bin/ls have the same inode (and the same sha-256 hash) but the number of hard links displayed by ls -li /usr/bin/ls /bin/ls is 1 instead of 2 :
user#debian:~/Documents/Unix$ ls -lai /usr/bin/ls /bin/ls
8258848 -rwxr-xr-x 1 root root 147176 24 sept. 2020 /bin/ls
8258848 -rwxr-xr-x 1 root root 147176 24 sept. 2020 /usr/bin/ls
Could somebody explain me what I have misunderstood?
I was puzzled for a while by this too, until I discovered this:
$ ls -ld /bin
lrwxrwxrwx 1 root root 7 May 31 02:39 /bin -> usr/bin
So /bin is just a symlink to /usr/bin, and there is really only one link to the file.
There are no differences between ls utility. You should know the difference is only between /bin and /usr/bin directories. /bin directory contains all programs that are used by system admin and all others users. /bin directory we can access whenever we want, but /usr/bin is accessible only for users that are locally logged.

Why Ubuntu 18.04 use `/sbin/init` instead of `systemd`? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
First of all, Here is my environment of system:
# cat /proc/version
Linux version 4.15.0-52-generic (buildd#lgw01-amd64-051) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #56-Ubuntu SMP Tue Jun 4 22:49:08 UTC 2019
# cat /etc/issue
Ubuntu 18.04.2 LTS \n \l
Refer to this Ubuntu Wiki, ubuntu has used Systemd by default since 15.04 and Systemd runs with PID 1 as /sbin/init. However, I found the different result on my ubuntu 18.04:
# ps aux | awk '$2==1{print $0}'
root 1 0.0 0.8 159692 8784 ? Ss Oct24 0:21 /sbin/init noibrs splash
# lsof -p 1 | grep txt
systemd 1 root txt REG 252,1 1595792 927033 /lib/systemd/systemd
So, my question is that:
Why Ubuntu 18.04 use /sbin/init instead of /lib/systemd/systemd?
Why lsof -p 1 | grep txt return /lib/systemd/systemd while the process of PID 1 is /sbin/init?
/sbin/init is a symbolic link to /lib/systemd/systemd
Take a look at the output of stat /sbin/init or readlink /sbin/init
This is what they mean by systemd "running as /sbin/init". The systemd binary is linked as /sbin/init and started by that link name.
Update
To further explain the difference between the ps and lsof output: ps is showing the command that started the process, while lsof is showing which files a process has opened.
When systemd was started, it was called by /sbin/init noibrs splash, the file system resolved the link to the file /lib/systemd/systemd which was then read from disk and executed.

can't change to sudoers.d directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
Simple question: I have a user called "user" on my system. This user has sudo privileges. Why can't I browse into the sudoer.d directory then?
Is it because cd is a built-in command?
[user#localhost etc]$ ls -al | grep sudoers.d
drwxr-x---. 2 root root 4096 Apr 4 18:09 sudoers.d
[user#localhost etc]$ sudo cd sudoers.d
[user#localhost etc]$ pwd
/etc
[user#localhost etc]$ sudo ls -la sudoers.d/
total 12
drwxr-x---. 2 root root 4096 Apr 4 18:09 .
drwxr-xr-x. 79 root root 4096 May 5 05:20 ..
-r--r-----. 1 root root 33 Apr 4 18:09 vagrant
[user#localhost etc]$ sudo vim sudoers.d/vagrant
[user#localhost etc]$
Thanks a lot.
It happens because sudo simply executes the command executable you pass to it with elevated privileges, and forwards the rest of arguments. Since cd is a shell builtin, sudo won't find the file to execute, which results in an error.
If you wish to have an interactive shell with elevated privileges, use sudo su
sudo opens a new shell. That shell changes its working directory. And then it exits. The original shell's working directory is never changed, nor can it be.

Chown not working [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
On Ubuntu 12.04, the chown command doesn't seem to be working like it should
root#server:/var/www/folder/# ls -al
Running this puts out
drwxr-xr-x 11 776 sftponly 4096 Feb 17 14:08 Other_Folder
I need write permissions for the group, so I run:
chown -R 776 ./Other_Folder
Then when I run ls -al again, the output is still
drwxr-xr-x 11 776 sftponly 4096 Feb 17 14:08 Other_Folder
chown is used to change ownership of the file, not change permissions.
ls -al is not showing you who owns the file, just its permissions.
If root owns those files, you'll need to chown them properly, before you can change their permissions:
chown -R yourname:yourname folderName
Then as the owner you can change their permissions:
chmod -R 776 folderName
Edit:
I double checked the syntax and it seems to be right, you'll likely need to use sudo to use them.

Resources