We can use cd – to access the most recently accessed folder, but what if I want to quickly switch to the last but one folder accessed? Answer Sure there’s a way! You want the shell builtin pushd.
Tag: linux
Undefined reference error while compiling
I’m trying to compile a project that has multiple *.c files and *.h file when I type the following command: the hdr folder is where the *.h files are located, the .o files are created but when I try to link them using the command: I see errors Answer Using a Makefile is very common for this task example…
common profile to record ssh sessions
I need to be able to record all ssh sessions on my server. After fumbling around with pam.d auditd, I found this enter link description here. And it looks to be working pretty well. However, when you “clear” the screen, your session log gets wiped as well. Is is possible to open a new log file whe…
Environment variables missing when executing via pkexec
If I execute print os.environ without pkexec I get lots of useful system environment variables, however, once I execute with, most of them are gone. How can I get them back with using pkexec? I understand there’s a workaround using sudo but haven’t found one yet for pkexec Answer In short, you can…
Change child process’ termination signal at runtime
Using clone() to fork a process you can specify the signal a child process should send its parent on death instead the “normal” SIGCHLD. Is it possible to change the set termination signal after the child was created? Either by the child or the parent? Answer I (quickly) scanned Linux’ sourc…
loadable library and perl binaries are mismatched
Can not run Pac-manager after installing deb file, Downloaded Pac Manger from : https://sourceforge.net/projects/pacmanager/ When run pac in the terminal , showing below problem xs/Vte.c: loadable library and perl binaries are mismatched (got handshake key 0xdb00080, needed 0xdb80080) System: Linux PC-pc 4.4.…
How do I match and kill a specific process without accidentally including unrelated processes?
I have two Tomcat processes, one is called event-ws, another is called app-event-ws. I sometimes need to kill event-ws from a shell script: The above will find and kill both of them; how can I find exactly find one of them? Answer pgrep / pkill are the best tools to use in this case, instead of ps: Each comma…
For zless to read empty gz file
I have tried to use zless to read (.gz) files. However, when (.gz) file is empty, it shows a message How to force zless to read an empty gz file without typing Y for many times. or Is that possible to return something like Answer zless is just a wrapper around less. You need to look at man less: -f
calling std::system with parameter containing space in double quotes
I need to call a linux std::system call with parameter than contain string with spaces. In order to process it correctly using argc / argv I want to pass it with double quotes. std::string cmdline = “myprogram -d “I am a sting”” ; if I cout this string I get good results. When I send i…
Linux get context switch timing
I’m implementing some form of internal profiler. Is there a way to know when and for how long a thread is context switched out? I know windows has it w the event tracing api and I know perf logs how many context switches happens. Is there a way to do it on linux? Needing root privileges is not an issue