You are not logged in.

#1 2020-05-30 19:03

franky44
Member
Registered: 2020-05-30
Posts: 28

Get away from typing password.

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

#2 2020-05-30 23:02

Dai_trying
Member
From: UK
Registered: 2015-12-14
Posts: 2,989

Re: Get away from typing password.

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

#3 2020-05-31 13:17

franky44
Member
Registered: 2020-05-30
Posts: 28

Re: Get away from typing password.

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

#4 2020-05-31 20:04

Dai_trying
Member
From: UK
Registered: 2015-12-14
Posts: 2,989

Re: Get away from typing password.

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

#5 2020-06-01 17:09

franky44
Member
Registered: 2020-05-30
Posts: 28

Re: Get away from typing password.

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

#6 2020-06-01 22:45

Dai_trying
Member
From: UK
Registered: 2015-12-14
Posts: 2,989

Re: Get away from typing password.

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 wink

Offline

#7 2020-06-02 00:18

JimW
Member
Registered: 2015-12-08
Posts: 400

Re: Get away from typing password.

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

#8 2020-06-02 07:37

Dai_trying
Member
From: UK
Registered: 2015-12-14
Posts: 2,989

Re: Get away from typing password.

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

#9 2020-06-05 13:18

franky44
Member
Registered: 2020-05-30
Posts: 28

Re: Get away from typing password.

"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

#10 2020-06-05 15:31

Dai_trying
Member
From: UK
Registered: 2015-12-14
Posts: 2,989

Re: Get away from typing password.

init is a root command and it's location is /usr/sbin/init which means you need root access for it (as mentioned earlier).

I wrote:

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

Board footer

Powered by FluxBB