How to run strace on ulimit command?
Environment
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
Issue
- Running
straceonulimitcommand fails with below error:
# strace ulimit
strace: Can't stat 'ulimit': No such file or directory
Resolution
Below is the workaround for Red Hat Enterprise Linux 6 and Red Hat Enterprise Linux 7
- Create file named as
ulimitunder/usr/bin/directory and edit to call the builtin functionulimit.
# vi /usr/bin/ulimit
#!/bin/sh
builtin ulimit "$@"
- Make
/usr/bin/ulimitexecutable :
# chmod +x /usr/bin/ulimit
- After following above steps
stracewill run onulimitsuccessfully. - Red Hat Enterprise Linux 8 Beta has the
/usr/bin/ulimitexecutable file by default provided bybashrpm:
# rpm -ql bash-4.4.19-6.el8.x86_64 | grep -i ulimit
/usr/bin/ulimit
--
# cat /usr/bin/ulimit
#!/bin/sh
builtin ulimit "$@"
Root Cause
ulimitis a builtin function ofbashrpm. But whenstraceruns, it looks forulimitfile and returns errorstrace: Can't stat 'ulimit': No such file or directoryas it could not find it.
Diagnostic Steps
ulimitfile does not exist by default under any path of the executables. Hencestracereturns error when it runs onulimit.- Verification of
ulimitbywhichcommand, shows file is not present inRed Hat Enterprise Linux 6andRed Hat Enterprise Linux 7:
# which ulimit
/usr/bin/which: no ulimit in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments