I know this is probably really basic, but I'm not sure how to open a file with root priviledges in the terminal

I was following a guide which I am not allowed to link,
But that said:

Open /usr/bin/xflock4 as root and comment out this line:

LOCK_CMD=$(xfconf-query -c xfce4-session -p /general/LockCommand) #put a # in beginning of the line

Install xfce4-screensaver:

sudo pacman -S xfce4-screensaver

Open the Screensaver app from the launcher. It will prompt you the first time to enable the service so click Yes and done :wink:

, and it told me to open the file with root priveledges. I know some terminal commands, but I’ll admit I’m not very familiar with it, and I wasn’t quite sure how to do that.

I tried typing

sudo -e /bin/xflock4

but that only opened what appeared to be an emply file, not a place where I could comment out a line of code. Any help?

EDIT: I was trying to stop the OS autofreezing apps when I lock the screen.

You are close, but you also need a program to open with. In terminal, usually you open with a text editor like nano, so:

sudo nano path/to/file

-e is a variable to sudo, so you add it after sudo (it’s optional). If you want to check what it does, type in terminal:

man sudo - that opens manual for sudo

for -e it shows “-e, --edit Edit one or more files instead of running a command. In lieu of a path name, the string “sudoedit” is used when consulting the security policy.”

To be frank, the manual explanations are often dry and not comprehensible for a regular user, but it’s better than nothing.

But maybe tell us first what you want to achieve, and we’ll try to help you understand what you need to do, how and why. Using sudo or root commands without knowing what they do is dangerous.

2 Likes

By ‘open’ I believe it is asking you to ‘edit’ the file as a text file. Somewhat confusing language is unpleasant, ambiguous and dangerous - and renders guides unsuitable for people who actually need them. Experience helps a lot with interpretation…

So what to do - do you have a favourite editor? like ‘vim’ or ‘neovim’ or ‘micro’ which I think is easy to learn and use (easier than ‘nano’).

So then you can do sudo micro /usr/bin/xflock4

I can’t do a test to give you screenshots, but I actually enjoy GUI text editors - in which case you don’t open them with root priviliges.

For example, if you have Visual Studio Code installed, or something like that

community/code 1.68.1-1 [12.69MiB 88.34MiB]
    The Open Source build of Visual Studio Code (vscode) editor

Then you can simply OPEN a file with

code  /usr/bin/xflock4

You can edit the file, but you cannot save it.
Code will attempt to autosave the file but will fail, and then you will see an option to ‘retry as sudo’.

The same happens with KDE’s ‘KATE’ editor. These are good editors, and will request escalation of privilege to save a file.

I must say that I really like micro - you can use your mouse to select stuff, and it has decent highlighting. You pull up shortcuts by pressing ‘Alt-g’ and if you press ‘Alt-g’ you get the bottom half of the editor to show you a help guide too - so you can’t get stuck, or lost, in Micro by forgetting what those funny hat or colon symbols mean.

So yes, choose some options for editing text - GUI and Terminal - and get comfy.

And lets be clear - following guides like this, you’re asking for trouble IMO. What’s your plan of action?

Screensavers are pretty old-hat TBH, I mean you can run one just to see how it looks, but there’s not much use in actually using one these days (I haven’t for over ten years now).

1 Like

I needed to stop it autofreezing apps when I lock the screen.

I opened /bin/xflock4 with gedit, but it still opened an empty file? I thought it was meant to contain something?

From the guide you quoted above, that’s not where the file is.

1 Like

Is it litarally /urs, or is it depending on what my user actually is?

It’s literally /usr.

Still a blank file.

The file location is:
/usr/bin/xflock4

It’s in your initial post even.
Why are you using a different path and then wonder why the file is not there? :wink:

I wouldn’t edit that file - your addition will be overwritten once the package
xfce4-session
which contains that file
gets updated.

Can’t you simply disable the xfce screensaver via the system settings?
I’m pretty sure you can - I know I have it disabled this way.

… if that is what you are trying to do
by trying to implement what that post you cited tells you to do …

… What are you trying to achieve by editing that file?

2 Likes

One EXTREMELY basic skill which many Linux users have developed and honed to a fine art over the years…

Apart from reading and typing… MUCH more important than that…

It’s an art form, worth practicing for a while, nay - every day, for hours and hours until you get it down.

The art of COPY and PASTE.

There are many ways to do this.

Open `/usr/bin/xflock4` as root and comment out this line:

First is to use the mouse to select the text.
Second is to click where you’re writing and spam your MIDDLE MOUSE button like this:
/usr/bin/xflock4 /usr/bin/xflock4 /usr/bin/xflock4

It’s great fun - have a go.

Update:
XFCE uses mousepad editor - so I’m curious why you are trying to use Gedit (that’s proper bloat for an XFCE desktop - if you want bloat, go for KDE or GNOME).

So to edit, you do ‘sudo mousepad /path/filename’ in a terminal.
To browse, hit the menu, type ‘file’ and launch the file browser (that’s gonna be Thunar if I’m not mistaken) and you can type in the path ‘/usr/bin’. Then you can click to see what’s in bin (select the list view with Ctrl_2) where you’ll find ‘xflock4’ which is a shell script…

Right click reveals ‘edit with Mousepad’. Mousepad doesn’t request elevated privileges (it’s very light and basic) so you can open a terminal and type ‘sudo mousepad /usr/bin/xflock4’
Then you press Ctrl+F which generally means ‘find’ to search text.
Then you type ‘xfconf’ to locate the information in your post…

You will see the line LOCK_CMD=$(xfconf-query -c xfce4-session -p /general/LockCommand)

You put your cursor at the start of that line, then on the keyboard you press ### and space. This to make it easy to search ‘###’ later and remove it.

Save, Exit, Done.

1 Like