Questions tagged [lock]

Use for questions regarding the mechanism to prevent concurrent access to shared resources by means of lock files or in-memory synchronization primitives. For the mechanism to prevent access to unattended desktop computers, use "screen-lock" instead. For questions regarding the unresponsive computer programs, use "freeze" instead.

Filter by
Sorted by
Tagged with
1 vote
1 answer
39 views

Unix-esque partial-file-locking mechanism

Linux and AFAIK most unixes expose the flock syscall for mandatory file-locking. My experience is admittedly limited with this, however am informed that it is kernel-enforced on the entire resource. ...
J-Cake's user avatar
  • 155
0 votes
0 answers
179 views

Lock icon suddenly appearing on folders in Ubuntu's /dev/sda8 partition

I'm encountering an issue on my Ubuntu system where folders in the /dev/sda8 partition shows a lock icon for some time then it goes away. It happened twice. In that locked state if I try to run any ...
RIR360's user avatar
  • 1
0 votes
0 answers
118 views

What's the best way to lock a directory from remove & edits?

I have a few directories that I want to lock. This lock should provide the following: Disallow anyone (including myself) from removing from that directory without a password Disallow anyone (...
David's user avatar
  • 153
3 votes
0 answers
250 views

elegant atomic distributed locking from bash/python?

In order to ensure non-concurrent execution of some code by multiple processes on a single node, I can implement advisory locking based on some atomic command (e.g. ln or mkdir) or I can use flock. ...
Alexis Huxley's user avatar
3 votes
1 answer
81 views

file locking mandated by OS/filesystem rather than opted into by file accessors?

Is there a way to have the OS (specifically, FreeBSD) or filesystem (specifically, ZFS) enforce that all access (or, at least, all non-root access, I guess) to a certain file must be done while the ...
Bob Vesterman's user avatar
0 votes
1 answer
46 views

Can a program tell whether I have a file open in an editor?

I have a file that I edit by hand (using emacs in a terminal window). I have a script that then reads the file, checks it for errors, and also modifies it by doing things like sorting lists in ...
jsdfhglskjghl's user avatar
5 votes
3 answers
780 views

Lock a bash script based on parameter?

I'm trying to find a way to lock a script based on a parameter given, but was unsuccessful in finding a proper answer. What I'm trying to achieve is prevent another user from running a script based on ...
classicmusiclover's user avatar
2 votes
3 answers
5k views

How To enable/disable "Lock Screen" setting from Linux terminal?

Please, do NOT say how to lock screen, i know how to do it. How To enable/disable Lock Screen service from terminal? Looks it's using xflock4 for locking screen. I can enable or disable it in ...
salto lenin's user avatar
0 votes
1 answer
75 views

How to customize default linux/unix PAM module faillock to lock user in all nodes in a cluster

I have implemented faillock in all nodes in cluster, so If any user failed login attempts three time through ssh he will be locked for certain period.It is working fine on individual node but I wanted ...
akash kumar's user avatar
0 votes
0 answers
986 views

apt-get autoremove --purge -y seems to be stuck

I'm not entirely sure why this is happening, so it seemed wise to ask here before I interfere with it. I'm attempting to install nasm, but I get the message: Waiting for cache lock: Could not get lock ...
Michael Macha's user avatar
2 votes
0 answers
401 views

Automatically lock my Linux computer when I walk away from it

I would like to lock my Linux (GNOME) machine after I walk away from it. Ideally, it should be a small Bluetooth tag / card that I carry in my pocket with a proximity sensor. Is there some software ...
martins16321's user avatar
1 vote
1 answer
1k views

How do I make Linux Mint stop pestering me for passwords all the time?

I run Linux Mint in a VM. Every single time I look at it, it has gone into some sort of "lock screen"-like state where it requires me to enter a password to get back. This is very annoying. ...
Frink Engelage's user avatar
0 votes
1 answer
1k views

Does locking in gnome allow background tasks like uplaoding to keep running?

I am uploading things in the back and want to lock the screen, but am not sure if the lock function in gnome locks the screen while allowing that to continue. So far it seems that the computer is not ...
user avatar
2 votes
0 answers
253 views

Debug & analyze pthread_mutex_lock issues

I've being recently facing some hardcore issues with Mutex lock for Linux, notably MySQL, memcache & APCu. Example: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting ...
Wiika's user avatar
  • 121
0 votes
0 answers
48 views

System locking up upon shutting down

Today upon shutting down my System I was greeted with loads of errors and informations i do not understand. This happened yesterday also and it didn't seem to continue to shut down "normally"...
rafe's user avatar
  • 13
1 vote
0 answers
69 views

Need utility to measure lock contention and thread Migration Rate

I Know it is trivial question but I searched several days for a utility to measure lock contention and thread migration rate but no luck.
Haifa_ash's user avatar
6 votes
1 answer
661 views

Code works in bash, not in zsh -- flock on arbitrary fd

Am new to shell scripting, and it makes me wonder why the following snippet does not work in zsh but does in bash? Is there a zsh equivalent of the same snippet? I get error parse error near `200' ( ...
codepoet's user avatar
  • 586
0 votes
1 answer
888 views

Watchdog message about CPU soft lockup in Fedora

I am running Fedora 34 KDE on my ASUS ZenBook Flip 14 with an Intel 11th Gen i7. It seems like every few minutes, I get this error message: watchdog: BUG: soft lockup - CPU#7 stuck for 22s! [swapper/7:...
Alex Shaw's user avatar
1 vote
0 answers
311 views

How to specify which display i3-lock starts showing the image on?

I sometimes use a monitor with my laptop. I use i3lock -t -i /path as my locking command and the image I use is of the resolution of my laptop screen. Running this with the monitor connected the puts ...
dnaik's user avatar
  • 145
1 vote
1 answer
638 views

laptop keyboard locks up after closing lid

I have a Dell Latitude 5500 and a Dell Latitude 7550. The 5500 has Debian 10 and KDE, and the 7550 has Ubuntu 20.04 with KDE. In both laptops, if I close the lid, when I open it later the built-in ...
raphael75's user avatar
  • 703
3 votes
2 answers
9k views

Arch linux: i3wm set lock time out (xss-lock i3lock)

I use arch with i3wm. I have enabled i3lock in my .config/i3/config: exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock Problem is my computer locks like every 10 minutes. How can I set ...
Jan Černý's user avatar
  • 1,331
0 votes
2 answers
4k views

xautolock configuration in Arch i3

After recently switching to i3 in Arch, I need something to manage power. xautolock seemed to be a good choice. Unfortunately, I need it to do both systemctl suspend and i3lock at the same time, but ...
user avatar
0 votes
0 answers
503 views

Get the lock status of an account on Solaris

I do not have root privileges. I wish to get the lock status of a given account say mwss I'm on Sun Solaris uname -a SunOS myhost 5.11 11.4.27.82.1 sun4v sparc sun4v Below is the output from shadow ...
Ashar's user avatar
  • 491
-3 votes
2 answers
1k views

is there a really simple and reliable way to create a unique lock (file) on linux? without using `flock` [closed]

EDIT: I learned how to use flock for exclusive lock and how to not mess with it: https://superuser.com/questions/1619940/flock-is-randomly-failing-on-desktop-pc-but-not-on-notebook-could-be-defectiv/. ...
Aquarius Power's user avatar
3 votes
1 answer
2k views

Trying to use xautolock to suspend activity after a certain amount of time

I'm using manjaro (5.8.18-1-MANJARO) and the i3 window manager. I'm trying to lock the screen then suspend activity after given amounts of idle time. I've found that xautolock should suit my needs ...
Raphaël Ventura's user avatar
-1 votes
1 answer
230 views

Locking a file to (over)writing [closed]

I have a poorly designed build script that always overwrites files that it shouldn't; if I edit these files and then run the script, it overwrites their content and, thus, the build fails. How can I &...
Sebi's user avatar
  • 1,009
1 vote
1 answer
2k views

Function Lock. can't disable

I'm using a Feker Machinist 01. On both Manjaro and Linux Mint (both running cinnamon), the function keys are "locked" to those silly laptop features like enabling/disabling wifi, adjusting ...
TheIronKnuckle's user avatar
0 votes
1 answer
714 views

What permission does the "lock" group in /etc/group grant?

I'm running Fedora. $ ls -l /dev/ttyACM0 crw-rw----. 1 root dialout 166, 0 Jul 4 10:50 /dev/ttyACM0 I was not able to access /dev/tty/ACM0 (dynamic usb serial with an Arduino on the other end), ...
Joshua Clayton's user avatar
9 votes
3 answers
7k views

Handling of stale file locks in Linux and robust usage of flock

I have a script I execute via cron regularly (every few minutes). However the script should not run multiple times in parallel and it sometimes runs a bit longer, thus I wanted to implement some ...
hanno's user avatar
  • 131
0 votes
1 answer
767 views

"sudo apt autoremove" command doesn't work ("/var/cache/debconf/config.dat is locked by another process")

I've tried solutions like editing on panasoniclpd.init file and it doesn't work too. This problem keeps shown whenever I try to update or install from the CLI sudo apt autoremove [sudo] password for ...
Madara's Mind's user avatar
0 votes
1 answer
3k views

A VNC server is already running, but no lock file for that

Although there is no X11 lock on display 12, vncserver can not start that display number due to a "VNC server that is running on 12". # rm /tmp/.X12-lock rm: cannot remove ‘/tmp/.X12-lock’: No such ...
mahmood's user avatar
  • 1,191
2 votes
3 answers
20k views

Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

(base) rusiru@rusiru-X556UV:~$ sudo apt-get upgrade Reading packages lists... Done Building dependency tree Reading state information... Done E: The package packettracer needs to be installed, but I ...
rusiru thushara's user avatar
0 votes
3 answers
4k views

How to install nfslock daemon

I want to learn the NFS locking mechanism I surfed on net. Using nfslockd or rpc.lockd we can do. But in Debian there is no package. Anyone please help me whether shall we do or not in Debian.
Rajalakshmi's user avatar
4 votes
2 answers
4k views

zsh: locking failed for ~/.cache/zsh/zsh_history: file exists

I have a bind mount ~/.cache/zsh folder between multiple hosts with rw and defaults when doing mount. When I start both machine and zsh trying to lock zsh_history, it gives error zsh: locking failed ...
Tuyen Pham's user avatar
  • 1,805
3 votes
1 answer
3k views

Cannot open access to console, the root account is locked after upgrade linux mint kernel

According to pervious question: Halt in Linux mint logo after update and upgrade After changing the GRUB file to: linux /boot/.... ro quiet text When I suspend the OS, I am going to loging page: ...
user296115's user avatar
2 votes
2 answers
8k views

file access blocked by a lock - how to remove?

I am trying to run the "check" function of backup program "restic" on one of the backup repositories it's created. No matter what I do, it crashes due to a fatal "already locked" problem. Here is the ...
Tom Cloyd's user avatar
1 vote
0 answers
266 views

My SSD has unexpected inconsistencies showing up after some time of usage

I have Ubuntu installed on my Kingston SSD. 4.15.0-55-generic #60-Ubuntu SMP Tue Jul 2 18:22:20 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux The system itself is quite smooth, but I have a major data ...
Karol Szustakowski's user avatar
0 votes
0 answers
392 views

Unable to wake up after locking screen

Just installed Xubuntu 19.04. When I try to lock my screen it does some weird and crashes. Screen turns off and I have to turn the system off manually. Tried xscreensaver and it works just fine, but I ...
Mr. Chicken's user avatar
2 votes
2 answers
1k views

Lock file naming pattern

Whenever I open a LibreOffice document, LibreOffice creates a lock file along the original file. This file has a naming schema like the following: .~lock.MyDocument.odt# Is this a LibreOffice ...
Silicomancer's user avatar
25 votes
3 answers
4k views

How does this script ensure that only one instance of itself is running?

On 19 Aug 2013, Randal L. Schwartz posted this shell script, which was intended to ensure, on Linux, "that only one instance of [the] script is running, without race conditions or having to clean up ...
user avatar
2 votes
0 answers
268 views

About `page_table_lock` in Linux process address space

I'm reading a tutorial about Linux page table, in the linked page Each process has its own page tables (threads share them). The pgd field of the memory descriptor points to the process's page ...
Kindred's user avatar
  • 284
4 votes
2 answers
476 views

Lock Virtual Terminals when resuming

Many screen lockers (mine is i3lock) do not block access to other Virtual Terminals. This means that, if I leave a session opened in some VT, then even when the desktop is locked (for example when ...
Maëlan's user avatar
  • 426
0 votes
0 answers
528 views

Does pid file work by assuming pid is not usable?

To use a pid file for ensuring singleton running instance of a program, I thought that when a process finishes running the program, it should remove the pid file, until I know it doesn't when reading ...
Tim's user avatar
  • 101k
0 votes
2 answers
481 views

Can we tell if a command is being run by a process or not, by looking at the flock lock file alone?

Is util-linux's flock implemented based on flock() in Linux C API? Can we tell if a command is being run by a process or not, by looking at the lock file alone? I found that when a command guarded by ...
Tim's user avatar
  • 101k
4 votes
1 answer
976 views

Is pseudo terminals ( unlockpt / TIOCSPTLCK ) a security feature?

After having opened the master part of a pseude-terminal int fd_pseudo_term_master = open("/dev/ptmx",O_RDWR); there is the file /dev/pts/[NUMBER] created, representing the slave part of he ...
humanityANDpeace's user avatar
0 votes
1 answer
523 views

Why "a lock file is the best approach if the resource is not a regular file, so using methods for locking files does not apply"?

Thanks to Mark's comment, pointing me to https://en.wikipedia.org/wiki/File_locking#Lock_files which says Shell scripts and other programs often use a strategy similar to the use of file locking: ...
Tim's user avatar
  • 101k
1 vote
1 answer
603 views

Allow DPMS to turn off screen with force when the screen is locked?

I discover that command xset dpms 300 which turn off the screen for example after 5 minutes (300s), and it wonderfully doesn't turn off the screen if a youtube video is actually playing even in a ...
SanjiBukai's user avatar
1 vote
2 answers
3k views

SELinux - How to avoid it preventing a process from write access on newly created files into folder

I'm hardly trying to correctly use selinux keeping it in enforced mode, but very often I encounter issues with it causing our application to work improperly. Our web application is java backend and ...
lese's user avatar
  • 2,726
1 vote
1 answer
332 views

Where is official documentation about locking mechanisms for etckeeper, apt, and/or dpkg?

Context: Want to put a lock on etckeeper/apt hook activity during special backup. Objective is to preserve whole package integrity, e.g., wait until any package installation is complete, and then ...
Craig  Hicks's user avatar
0 votes
2 answers
571 views

Getting Information about locks associated with a process

I am unable to list the locks associated with a process and information about the locks i.e How many threads share this lock etc. Kindly tell my how to extract this information from a process ID. My ...
Muhammad Umer Saeed's user avatar