Basic terminal commands

  1. Is sudo pacman -Syyu equivalent to sudo apt-get update && sudo apt-get upgrade in Debian?
  2. Is there something that I can add to it to get past all the prompts for yes, such as the -y in Debian?
  3. What about sudo apt-get clean && sudo apt-get autoclean && sudo apt-get autoremove which cleans packages and obsolete and orphaned packages?

Pacman is used without “sudo” and when it needs it will ask for your password

Please be carefull when updating. Manjaro needs an owner who cares for it (and reads logs :wink: )

man pacman
3 Likes

https://wiki.archlinux.org/title/Pacman/Rosetta

2 Likes

Um, not for installing or uninstalling packages it isn’t. Or are you thinking about pamac? pamac will indeed prompt you for a password when needed and should not be used with sudo.

2 Likes

I think that the only commands I need are:

sudo pacman -Sc

Clean up all local caches.

sudo pacman -Qdtq | pacman -Rs -

Remove dependencies that are no longer needed (orphans)

Do you think there anymore that an average user like me would use?

I was not replying to you but to @andreas85. :slight_smile:

Or… :arrow_down:

sudo paccache -rvk0

… which does the same thing. :slight_smile:

Always be careful with that. Sometimes packages are marked as orphans when they were explicitly installed.

man pacman
man pamac
man paccache
man mhwd
man apropos
...

:slight_smile:

Here I would simply suggest RTFM.

one of my favourite ‘RTFM’ aids is tldr++

pamac install tldr++ Then do tldr pacman


You’ll get an interactive playground to play with it.

Also I’d suggest you have a go with fish terminal.

Start by installing fish, then type ‘fish’ to start it up (no need to change the shell).

Then try pacman - and hit tab to get this:

Screenshot_20220814_103417

It means you can add flags one by one and see what’s next - build your sentence.

For example, do man pacman | rg -Sy (rg is ripgrep).

Also don’t forget pacman --help.

For installing, we should really use pamac… alias install=pamac install
For upgrading we can do alias upgrade=pamac upgrade --enable-downgrade --aur --devel
But if we change mirrors, we might need to do some more advanced operations - and allow downgrading of packages. Cross that bridge when you come to it :wink:

I do agree with your unspoken criticism that man pages are a bit of a pain.
For this reason I would suggest you try this:

man pacman > pacman.md (or .txt if you like) which will put a text file in your home directory.
Now open that pacman.md so you can have a personal copy, edit and highlight as you find useful.

It would open nicely in a Markdown editor/note application. I like Joplin, but right now I’m using Obsidian.


Obsidian would be an excellent way to extract parts of the ‘man’ page into personal ‘tips and tricks’ notes - which are all saved as separate .md files in the selected ‘notes’ directory.

1 Like

What if I get:

error: failed to init transaction (unable to lock database)
error: could not lock database: File exists
  if you're sure a package manager is not already
  running, you can remove /var/lib/pacman/db.lck

I get this with such command as pacman -Sc and sudo pacman -Qdtq | pacman -Rs -

you can remove /var/lib/pacman/db.lck

Thank you, but I tried remove /var/lib/pacman/db.lck and got bash: remove: command not found.

The command is rm not remove

rm /var/lib/pacman/db.lck gave me rm: remove write-protected regular empty file '/var/lib/pacman/db.lck'?

My bad…
Do you remember that if something is protected, or you don’t have permission, then you give it administrative permission (which can destroy your system if you like).

Also remember - don’t copy and paste from internet unless you understand it. I usually include deliberate edits or errors in commands in forums now… but that time I just repeated the line which I think makes the answer too obvious.
Screenshot_20220817_094702

Let me create a new file, and show you the ‘wrong’ way…
sudo touch /var/lib/pacman/db.lck will create an empty file to play with.
To save time I also did abbr rm 'rm -v -d -I in my FISH terminal, separate -I to easily remove it…
If you use bash or zsh then you add 'alias rm=‘rm -v -d -I’ to your bashrc or zshrc.

Now in terminal…
rm /var/lib/pacman/db.lck Ok, it’s interactive - type ‘Y’ to accept…


Woah, these beans aren’t cooked :frowning: What now?

Get the last command back (I press UP arrow)
Move the cursor goes to the start of the line (I press HOME key)
you type 'sudo ’ or 'doas ’
You enter your password.

Then you fall off your chair screaming with happiness.

I strongly suggest you install and try out Fish terminal BTW.

Then commands like ‘rm’ once you figure out you want to use it with rm -v -d -I can be set with abbr rm 'rm -v -d -I ' and will expand if you hit space after typing ‘rm’.

Also learn to use stuff like man rm and tldr rm

For ‘tldr’ you can install ‘tealdeer’ or something cool and interactive like tldr++ - it’s in alpha, but it’s fun and it’s small - and not difficult to simply install tldr and that will remove tldr++.

Use pamac - copy and do one line at a time.

pamac install fish
fish
pamac install tldr++
tldr pamac
pamac install tldr
tldr pamac

Woah, now that’s FUN.

Fish also uses colour out of the box… so if I remember wrongly (I have no ‘alias’ or ‘abbr’ for the word ‘remove’ - but I do have an alias for ‘purge’) then commands typed appear RED until they will work…
Screenshot_20220817_100851
Correctly typed they appear in blue…

And also, the reason I like to be able to use fish (not as default, but just by typing ‘fish’ to load it) is that it will give information.

So we type 'pamac what’s next??? Now hit :

You get a list underneath of options. Also pressing arrow up/down will scroll your history with suggestions containing ‘pamac’.

How did we delete that pacman thing?
type ‘pacman’ and then press the ‘UP’ arrow:

But anyway - thanks for the entertainment. I hope it gets easier for you soon.

Now if you didn’t already install Obsidian, you’d better get on with that now.
pamac install obsidian
Then launch it…
Then add useful snips of what you need…
In Firefox, visit MarkDownload - Markdown Web Clipper – Get this Extension for 🦊 Firefox (en-US)
Load THIS page and click the ‘M+’ extension icon.
You can now download this page as a Markdown file, which will appear in Obisidan if you set the right directory, and also can be opened with MarkText which is a rather lovely Markdown editor.

From pacman - ArchWiki (archlinux.org)

Warning: One should avoid deleting from the cache all past versions of installed packages and all uninstalled packages unless one desperately needs to free some disk space. This will prevent downgrading or reinstalling packages without downloading them again.

Okay, so cleaning the cache is potentially dangerous in Manjaro. I’m wondering if I should switch topaccache -rk1. What’s your opinion?

Well it’s only worth doing when you really need space…
I had no problems yet… but that looks ok.

Here’s my cleaner :stuck_out_tongue: I generally don’t use it often though.
alias clean='pamac clean --build-files && paccache -rvuk1 && sudo journalctl --vacuum-time=12h --rotate'

1 Like

No, It’s not!

All it is is that you lose the ability to go back to a prior version of a package
without re-downloading it again
which can be difficult, because only the current packages are easily available

you (obviously) do not have the previous, older, packages anymore - so you cannot easily go back by just installing the older version in the case you might want or need to do so.

It’s not dangerous.
Just keep 2 or even 3 previous versions if you are not tight on storage space.
although I never needed a package 2 levels older than what is current

1 Like

You’d do well to read the man page for pamac:

man pamac
1 Like

Get the last command back (I press UP arrow)
Move the cursor goes to the start of the line (I press HOME key)
you type 'sudo ’ or 'doas ’

Just type Alt + s in fish or sudo !! in other shells

2 Likes

Anything is dangerous, potentially.

But regarding the cache, I think a safer way to clean the cache is:

pamac clean

Because, according to the main page:

pamac clean [options]
Clean packages cache or build files
2 Likes