Usually for check the upgrade i use my pc by ssh and use this command:
sudo apt-get -y update && sudo apt-get -y -f dist-upgrade
My question it’s… it’s possibly to create a somethigs like a “link” or somethigs like a “alias” for this command ?
For example whit a “aliases” when logged to ssh i can only put a command like update and after it’s automatic launch the correctly command posted above ?
EDIT
Possibly similar question here:
Try to read…
EDIT 2
And i found it’s can possibly add aliases on .bashrc… yeah but where’s this files ??
I’d probably make a shell script with the desired commands in it, make it executable and put it somewhere like /usr/local/bin but there are other ways to do it like creating an alias.
I myself wouldn’t have the -y -f on the dist-upgrade command as i’d want to review the output first.
.bashrc is in your home directory (/home/osmc) as it have a . at the start of the filename it means it’s invisible so when running the ls command you need the -a argument. If just editing you can do this without needing to do anything.
i have choose to create a .bash_aliases on root folder how it’s suggested on .bashrc files in home folder.
But i thinks i need to reboot my pi2 for obtain this aliases works…
Meanwhile on .bashrc it’s suggested this:
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
I have created a new files… in /root and i thinks this files it’s loaded at boot… i need only to test it.
For -y in dist-upgrade… i have put this because i thinks it’s usefull. If it’s present some upgrade bacause not upgrade it’s directly ? OSMC it’s not a fully OS and the sources and all your upgrade it’s tested before to released… whitout -y i need only to answered yes
Put -y because I trust what is released from OSMC team
It’s not saying to put it in /root, it’s saying to put it in the home directory which is /home/osmc or sometimes referred to simply as ~
You don’t need to reboot to test these changes (I would as I’m lazy), you can simply re-read the .bash_aliases file to apply those changes now if you want.
I have need a explanation…how i need exactly to put the files ?? On /root of on /home/osmc ?
I have tryed to create a external files called .bash_aliases like it’s suggested on .bashrc bat apparently the alias it’s not works also after a reboot.
SSH into your device and create the file (it doesn’t exist by default) with; nano .bash_aliases
In the text editor window that comes up enter your desired aliases one per line. All my example one has in it is; alias update='sudo apt-get update && sudo apt-get dist-upgrade -y'
For clarity, the file is /home/osmc/.bash_aliases
Not in /root like you suggested earlier.
To answer at @ActionA and @jb2cool… i thinks i have understood how it’s works… try to explain:
I thinks the .bashrc files it’s be read/loaded every time i start a bash session or also a SSH session from my pc.
Example:
if i open a SSH using “root” as user it’s be loaded the file on:
/root/.bashrc
instead… if i open a SSH by me pc using “osmc” as user the file loaded it’s:
/home/omsc/.bashrc
Meanwhile how i have usually use the “root” user for my ssh config i have created this two files.
on /root/.bashrc i have put this:
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Instead i use “root” as user the symbol “~” report to /root… infact this portion of goes to be load /root/.bash_aliases files if exist and on this files i have put this:
alias update='clear && echo "Questo è il file su /root" && sleep 5 && echo "" && sudo apt-get update && sudo apt-get -y -f dist-upgrade'
alias restart='sudo systemctl restart mediacenter'
This is my .bash_alises files pushed on /root path… and now… IT’S WORK whitout any problems
I had to figure out just the question of “user” i stay to use for my SSH session… and THAT’S IT’S ALL
It’s all correct ?? If i commit some error say to me…
@jb2cool@ActionA i’m need to back to this trouble because i have found a possibly bug… try to explain what’s appened… this is my current bash_aliases file:
# Alias definitions.
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF
#alias <command>='command'
#file on /root
alias restart='sudo systemctl restart mediacenter'
alias update='clear && echo "Avvio il file sul ROOT..." && echo && sudo apt-get update && sudo apt-get -y -f dist-upgrade'
alias test1='sudo systemctl restart mediacenter'
When i launch SSH Session… the “restart” commands not work and obtain an error says:
Failed to restart mediacenter\x0d.service: Unit mediacenter\x0d.service failed to load: No such file or directory.
Also the “update” it’s not work!!! I obtain the error already say here!
Apparently only the “test1” WORK!!!
Only the LAST alias work… because ??? I don’t have absolutely idea…
I have also tryed to change order of alias…if i put the Alias update at Last line of files… this works and the other 2 no work… very strange!
osmc@192.168.0.37's password:
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Feb 24 16:11:08 2017 from desktop.local
osmc@osmctestpi:~$ cat .bash_aliases
alias ll='ls -la'
alias restart1='sudo systemctl restart mediacenter'
alias restart2='sudo systemctl restart mediacenter'
alias restart3='sudo systemctl restart mediacenter'
alias restart4='sudo systemctl restart mediacenter'
osmc@osmctestpi:~$ restart1
osmc@osmctestpi:~$ restart2
osmc@osmctestpi:~$ restart3
osmc@osmctestpi:~$ restart4
osmc@osmctestpi:~$
No problems here. They all behave as expected without issue.
I don’t have idea…this is my situation… look what’s appened on my osmc:
Using username "root".
root@192.168.1.4's password:
Send automatic password
Access denied
root@192.168.1.4's password:
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Feb 24 22:45:50 2017 from 192.168.1.2
-bash: $'\r': comando non trovato
root@osmc:~# cat ~/.bash_aliases
# Alias definitions.
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF
#alias <command>='command'
#file on /root
alias restart='sudo systemctl restart mediacenter'
alias update='clear && echo "Avvio il file sul ROOT..." && echo && sudo apt-get update && sudo apt-get -y -f dist-upgrade'
alias test1='ls -la'
root@osmc:~# test1
"s: opzione non valida -- "
Try 'ls --help' for more information.
root@osmc:~#
If i put the SAME alias directly on .bashrc apparently it’s working whitout any problems.
EDIT
I don’t have absolutely idea because that’s appened… but apparently if i put some alias on .bash_aliases only the last alias work correctly.
I have put the same alies directly on /root/.bashrc files and all aliases works…
It’s possibly the problems it’s kitty ?? It’s possibly the problems it’s my version of bash on my osmc setup ??
Or it’s possibly the problems it’s only because i use the “root” user ??