$sudo strace -e trace=signal -p 1 [sudo] password for jeffrin: Process 1 attached kill(4659, SIGTERM) = 0 kill(4659, SIGCONT) = 0 $gcc crtlc1-p1.c $./a.out Hello world Hello world Hello world Hello world Hello world Hello world Hello world Hello world Hello world ^Ci got a signal 2 Hello world Hello world ^C $cat crtlc1-p1.c #include …
Category Archives: operating system
Collecting information from sysfs about cpu events
$sudo cat /sys/devices/cpu/events/cache-misses event=0x81 $sudo cat /sys/devices/cpu/type 4 $sudo cat /sys/devices/cpu/events/branch-instructions event=0xc2 $sudo cat /sys/devices/cpu/events/branch-instructions event=0xc2 $sudo cat /sys/devices/cpu/events/branch-instructions event=0xc2 $sudo cat /sys/devices/cpu/events/branch-instructions event=0xc2 $sudo cat /sys/devices/cpu/events/branch-misses event=0xc3 $sudo cat /sys/devices/cpu/events/branch-misses event=0xc3 $sudo cat /sys/devices/cpu/events/cache-references event=0x80 $sudo cat /sys/devices/cpu/events/cpu-cycles event=0x76 $sudo cat /sys/devices/cpu/events/instructions event=0xc0 $
Example related — Recovering typical deleted file in GNU/Linux
$which glxgears /usr/bin/glxgears $rm /usr/bin/glxgears rm: remove write-protected regular file ‘/usr/bin/glxgears’? y rm: cannot remove ‘/usr/bin/glxgears’: Permission denied $sudo rm /usr/bin/glxgears [sudo] password for jeffrin: $ps aux | grep glxgears jeffrin 2469 4.4 0.6 157656 20888 pts/0 Sl+ 22:43 0:07 glxgears jeffrin 2515 0.0 0.0 12656 1560 pts/1 S+ 22:46 0:00 grep glxgears $sudo cat …
Continue reading “Example related — Recovering typical deleted file in GNU/Linux”
Example for – Trace all system calls which involve process management
$strace -e trace=process python dig.py execve(“/usr/bin/python”, [“python”, “dig.py”], [/* 39 vars */]) = 0 arch_prctl(ARCH_SET_FS, 0x7feb563b4700) = 0 I think lscpu command is using proc filesystem to get data. /* /sys paths */ #define _PATH_SYS_SYSTEM “/sys/devices/system” #define _PATH_SYS_CPU _PATH_SYS_SYSTEM “/cpu” #define _PATH_SYS_NODE _PATH_SYS_SYSTEM “/node” #define _PATH_PROC_XEN “/proc/xen” #define _PATH_PROC_XENCAP _PATH_PROC_XEN “/capabilities” #define _PATH_PROC_CPUINFO “/proc/cpuinfo” #define …
Continue reading “Example for – Trace all system calls which involve process management”
Hacking with strace to find about write calls in a program
$strace -e write python dig.py write(1, “\33[31mI think lscpu command is us”…, 69I think lscpu command is using proc filesystem to get data. ) = 69 write(1, “\33[31m/* /sys paths */\33[0m\n”, 26/* /sys paths */ ) = 26 write(1, “\33[31m#define _PATH_SYS_SYSTEM “…, 63#define _PATH_SYS_SYSTEM “/sys/devices/system” ) = 63 write(1, “\33[31m#define _PATH_SYS_CPU “…, 65#define _PATH_SYS_CPU _PATH_SYS_SYSTEM …
Continue reading “Hacking with strace to find about write calls in a program”
Internal of lscpu command
I think lscpu command is using proc filesystem to get data. /* /sys paths */ #define _PATH_SYS_SYSTEM “/sys/devices/system” #define _PATH_SYS_CPU _PATH_SYS_SYSTEM “/cpu” #define _PATH_SYS_NODE _PATH_SYS_SYSTEM “/node” #define _PATH_PROC_XEN “/proc/xen” #define _PATH_PROC_XENCAP _PATH_PROC_XEN “/capabilities” #define _PATH_PROC_CPUINFO “/proc/cpuinfo” #define _PATH_PROC_PCIDEVS “/proc/bus/pci/devices” #define _PATH_PROC_SYSINFO “/proc/sysinfo” #define _PATH_PROC_STATUS “/proc/self/status” #define _PATH_PROC_VZ “/proc/vz” #define _PATH_PROC_BC “/proc/bc” #define _PATH_PROC_DEVICETREE “/proc/device-tree” #define …
Looking into a few commands with python interactive shell
ABOUT PYTHON Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python has a design philosophy that emphasizes code readability, notably using significant whitespace. It provides constructs that enable clear programming on both small and large scales.[26] Van Rossum led the language community until stepping down …
Continue reading “Looking into a few commands with python interactive shell”
Hacking with listing local system locks
ABOUT lslocks lslocks lists information about all the currently held file locks in a Linux system. File locking is a mechanism that restricts access to a computer file by allowing only one user or process access at any specific time. Systems implement locking to prevent the classic interceding update scenario (see race condition). [bash] $lslocks …
Hacking with GNU grep . ( grep ‘[1-9]\$’ price.list )
$emacs price.list $grep ‘[1-9]$’ price.list 1 2 3 4 45 46 78 $54 $cat price.list 1 2 3 4 45 46 78 $54 54$ 31$ 21$ $grep ‘[1-9]’ price.list 1 2 3 4 45 46 78 $54 54$ 31$ 21$ $grep ‘[1-9]\$’ price.list 54$ 31$ 21$ $
Hacking with the quote command on Bash shell
ABOUT Quoting Quoting is used to remove the special meaning of certain characters or words to the shell. Quoting can be used to disable special treatment for special characters, to prevent reserved words from being recognized as such, and to prevent parameter expansion. Each of the shell metacharacters (*note Definitions::) has special meaning to the …
Continue reading “Hacking with the quote command on Bash shell”