You are not logged in.
Pages: 1
Howdy: I made some aliases for a few functions I do everyday. Some of them require my password. The whole idea behind the alias was to perform tasks that don't require further input. Here are my aliases:
To shut down or restart the computer: alias rest="init 0" and alias rset="init 6" each time it asks for the password.
To update and upgrade Q4OS: alias update="sudo apt update && apt upgrade" I know I have to put the sudo ahead of everything else. Is there a way I can give the password without typing it in?
Here are the other aliases I made in .bash_aliases.
alias ll='ls -l'
alias rest='sudo init 0'
alias rset='sudo init 6'
alias update='sudo apt update && apt upgrade'
alias lla='ls -la'
alias cls='clear'
The cls is from an old DOS command. Otherwise poor inconvenienced me has to type c-l-e-a-r. My fingers can hardly bear the strain.
Thanks everyone for any help.
Offline
You could configure sudo to not require a password for your command, I have never needed to do it myself but I'm sure a google search will throw up some examples.
Here's one but it's a general one and you might want to look at setting it just for your script rather than letting all users have that privilege.
https://www.tecmint.com/run-sudo-comman … ord-linux/
In fact if memory serves me right Q4OS used to be configured for the apt commands to be run without password as long as the user was in the sudo group so there might be an example in your /etc/sudoers file or in a file in /etc/sudoers.d/ .
Offline
Thanks for your suggestions I'll take a look at the web site. An idea occurred to me. What if I went into the password settings, and set the sudo to = mypassword?
I'll check out the web site first before I tinker around with settings.
Offline
Have a good read before trying anything (any site you find in a search should yield similar suggestions read a few if you can spare a little time), I don't use sudo this way myself as I don't feel the need in my circumstances, but it does have many many options depending on your required security needs.
Offline
I tried using the init command without the sudo. It didn't work. It returned "file not found." It will work if I include the sudo. Thinking about it, I came to realize that the need for sudo has to do with security. Without it, a security breach would let some juvenile delinquent get in, and raise all kinds of Hell. The only other time the "file not found (annoying) message" is when I use commands that that require an internet or network connection.
Offline
I tried using the init command without the sudo.
What did you actually try? (try to be exact as it might help better)
It didn't work. It returned "file not found." It will work if I include the sudo.
Most (if not all) commands that need root privileges are kept in a different location and cannot be found by normal user (usually) as they are not in the users $PATH using sudo changes the $PATH environment variable to include them.
Thinking about it, I came to realize that the need for sudo has to do with security. Without it, a security breach would let some juvenile delinquent get in, and raise all kinds of Hell.
A good analogy, although some die-harders might say having sudo itself is a risk and shouldn't be used but you have to make the balance between security and ease of use sometimes.
The only other time the "file not found (annoying) message" is when I use commands that that require an internet or network connection.
Same as other file not found answer.
And from you OP
The cls is from an old DOS command. Otherwise poor inconvenienced me has to type c-l-e-a-r. My fingers can hardly bear the strain.
I use Ctrl+l (that's a lower case L) to clear screen in terminal. And I remember those DOS days too
Offline
The only other time the "file not found (annoying) message" is when I use commands that that require an internet or network connection.
I have trouble remembering what it was (or when) but I do remember that I had a similar problem and found that if I used sudo before the command it quite often worked. Just a thought.
Offline
And an easy way to find out these things is to have the package command-not-found installed, that way you will get a better answer when a command is not found, Example:
dai@E5470:~$ ifconfig
Command 'ifconfig' is available in the following places
* /sbin/ifconfig
* /usr/sbin/ifconfig
The command could not be located because '/sbin:/usr/sbin' is not included in the PATH environment variable.
This is most likely caused by the lack of administrative privileges associated with your user account.
ifconfig: command not found
and without command-not-found package you would simply be told
dai@E5470:~$ ifconfig
ifconfig: command not found
And if the package is not installed you would get something like this
dave@E5470:~$ yotta
Command 'yotta' not found, but can be installed with:
sudo apt install yotta
I personally would like to see this installed and configured OOTB as it would be very helpful to anyone starting out using terminal commands, and I usually install it as a matter of course.
Offline
"What did you actually try? (try to be exact as it might help better)"
On the command line, I entered init 6, to reboot the system. If I use sudo in front of the command, it works.
I have several Linux books, but none of them address this problem. All of those books seem to be directed at first time Linux users. I'm not a first time user, but I'm somewhere between a Novice to Intermediate user.
Offline
init is a root command and it's location is /usr/sbin/init which means you need root access for it (as mentioned earlier).
Most (if not all) commands that need root privileges are kept in a different location and cannot be found by normal user (usually) as they are not in the users $PATH using sudo changes the $PATH environment variable to include them.
You will notice you have a folder /usr/bin and another /usr/sbin these have the commands for user (bin) and root (sbin), there are also bin and sbin folders in other locations and they follow the same principle.
Offline
Pages: 1