LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Bodhi
User Name
Password
Bodhi This forum is for the discussion of Bodhi Linux.

Notices


Reply
  Search this Thread
Old 07-06-2020, 03:14 PM   #16
enigma9o7
Senior Member
 
Registered: Jul 2018
Location: Silicon Valley
Distribution: Bodhi Linux
Posts: 1,388

Rep: Reputation: 560Reputation: 560Reputation: 560Reputation: 560Reputation: 560Reputation: 560

Quote:
Originally Posted by questionsBot View Post
Ok... so I have returned the original path files to their default state and now I am putting my scripts in /usr/local/bin this allows me to find them and type them anywhere in the terminal as well as sudo them if needed.
Yep, although if you keep them there it'll require you to use sudo just to put them there or edit/delete etc.

Not sure of use case why you need to execute the script as root, but if there's a command in script that needs root you can just put the sudo command in the script itself.... dunno if that's good practice but I do it. Then when script gets to first command that needs sudo it'll prompt you for password if you hadn't already provided password to sudo.
 
1 members found this post helpful.
Old 07-06-2020, 08:22 PM   #17
questionsBot
Member
 
Registered: Jun 2020
Posts: 104

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by enigma9o7 View Post
Yep, although if you keep them there it'll require you to use sudo just to put them there or edit/delete etc.

Not sure of use case why you need to execute the script as root, but if there's a command in script that needs root you can just put the sudo command in the script itself.... dunno if that's good practice but I do it. Then when script gets to first command that needs sudo it'll prompt you for password if you hadn't already provided password to sudo.
yeah I noticed that... I just didn't want people to be able to sudo it.

The only sudo scripts I have is suppdate and suninstall.

supdate
Code:
#!/bin/bash

#supdate Script
apt update -y && apt upgrade -y
suninstall
Code:
#!/bin/bash

#echo "Nice to meet you $1"

if test -z "$1" 
then
      echo "\You forgot to add a filename to uninstall"
else
      apt --purge remove $1 -y
      apt autoremove -y
      apt clean
fi

Last edited by questionsBot; 07-06-2020 at 08:24 PM.
 
Old 07-06-2020, 08:51 PM   #18
cordx
Member
 
Registered: Oct 2018
Location: texas
Distribution: bodhi 5.1.0
Posts: 797

Rep: Reputation: 184Reputation: 184
Quote:
Originally Posted by questionsBot View Post
supdate
Code:
#!/bin/bash

#supdate Script
apt update -y && apt upgrade -y
suninstall
Code:
#!/bin/bash

#echo "Nice to meet you $1"

if test -z "$1" 
then
      echo "\You forgot to add a filename to uninstall"
else
      apt --purge remove $1 -y
      apt autoremove -y
      apt clean
fi
alias supdate='sudo apt update -y && sudo apt upgrade -y' in .bashrc or .bash_aliases requires neither root permission to place them or edit them. any other user on your system would more than likely be able update, upgrade, purge or autoremove with their own sudo access.


i like that use of test. nice addition. i just read the other day that functions are also an option in .bashrc so sunintstall would probably work too. i just have never used one.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add the xyz directory to your path (what path?) Eerie Linux - Newbie 3 06-06-2012 04:48 PM
[SOLVED] Permanently add path to root via script? Porch Linux - Software 5 05-11-2010 04:37 PM
IPTables has a "drop all anywhere" and "accept all anywhere" Zero187 Linux - Security 4 06-18-2009 07:09 PM
add to root's path permanently linuxfia Ubuntu 3 04-14-2008 11:42 PM
Shell scripts unable to permanently change directory after exit ernesto_cgf Linux - General 4 12-21-2006 04:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Bodhi

All times are GMT -5. The time now is 07:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration