OS/Ubuntu

[Ubuntu] Upgrade without entering password in terminal

강서버 2025. 9. 12. 16:54
반응형

 

auto_upgrade.sh
0.00MB

 

(Shell file source code)

#!/bin/sh

echo ">>>>>>>>>>>>>>>>>>>> $ sudo apt update"
echo "Passw0rd" | sudo -S apt update
echo ""

echo ">>>>>>>>>>>>>>>>>>>> $ sudo apt upgrade -y"
sudo apt upgrade -y
echo ""

echo ">>>>>>>>>>>>>>>>>>>> $ sudo apt autoremove -y"
sudo apt autoremove -y
echo ""

 

1. Download the shell file above. (auto_upgrade.sh)

    (Perform update / upgrade / autoremove)

 

2. Editing the shell file with an editor. (changing the root password)

(before)

echo "Passw0rd" | sudo -S apt update

 

(after)

echo "your root password" | sudo -S apt update

 

3. Move the shell file to the bin directory of the user's home folder (create the bin folder if it does not exist)

ex) user name : ᅟuser

- user's home folder : /home/user

- bin directory : /home/user/bin

- final shell file path : /home/user/bin/auto_upgrade.sh

 

* Create the user home bin directory if it does not exist.

~$ mkdir bin

 

* Move shell file (example)

~$ cd Download

~/Download$ mv auto_upgrade.sh ~/bin

 

4. Add shell file user execution permissions.

~$ cd bin

~/bin$ chmod u+x auto_upgrade.sh

 

5. Reboot system

 

6. Shell execution

(* By default, the user's home bin directory is added to the path, so it can be executed from any path.)

~$ auto_upgrade.sh

 

(Execution log)

~$ auto_upgrade.sh
>>>>>>>>>>>>>>>>>>>> $ sudo apt update
기존:1 http://kr.archive.ubuntu.com/ubuntu noble InRelease
기존:2 http://kr.archive.ubuntu.com/ubuntu noble-updates InRelease             
기존:3 http://kr.archive.ubuntu.com/ubuntu noble-backports InRelease           
기존:4 https://packages.microsoft.com/repos/edge stable InRelease              
기존:5 https://packages.microsoft.com/repos/code stable InRelease              
기존:6 https://dl.google.com/linux/chrome/deb stable InRelease                 
기존:7 http://security.ubuntu.com/ubuntu noble-security InRelease              
받기:8 https://esm.ubuntu.com/apps/ubuntu noble-apps-security InRelease [7,613 B]
받기:9 https://esm.ubuntu.com/apps/ubuntu noble-apps-updates InRelease [7,480 B]
받기:10 https://esm.ubuntu.com/infra/ubuntu noble-infra-security InRelease [7,474 B]
받기:11 https://esm.ubuntu.com/infra/ubuntu noble-infra-updates InRelease [7,473 B]
내려받기 30.0 k바이트, 소요시간 3초 (9,471 바이트/초)
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다... 완료
상태 정보를 읽는 중입니다... 완료        
4 패키지를 업그레이드할 수 있습니다. 확인하려면 'apt list --upgradable'를 실행하십시오.

>>>>>>>>>>>>>>>>>>>> $ sudo apt upgrade -y
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다... 완료
상태 정보를 읽는 중입니다... 완료        
업그레이드를 계산하는 중입니다... 완료
다음 업그레이드는 단계적으로 배포될 예정으로, 나중에 업그레이드합니다:
  bind9-dnsutils bind9-host bind9-libs openssh-client
0개 업그레이드, 0개 새로 설치, 0개 제거 및 4개 업그레이드 안 함.

>>>>>>>>>>>>>>>>>>>> $ sudo apt autoremove -y
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다... 완료
상태 정보를 읽는 중입니다... 완료        
0개 업그레이드, 0개 새로 설치, 0개 제거 및 4개 업그레이드 안 함.

 

 

반응형