【Linux Tips】Miscellaneous Notes
→ 日本語版を読むRunning a File Without Execute Permission
Even a file without execute permission can be run if you have read permission by passing it as an argument to bash, source, etc.
$ id
uid=1001(test01) gid=1001(test01) groups=1001(test01)
$ ls -l test.sh
-rw-rw-r-- 1 test01 test01 5 Dec 9 23:24 test.sh
$ ./test.sh
bash: ./test.sh: Permission denied
$ bash test.sh
Sat Dec 9 23:24:24 JST 2023
$ ls -l /usr/bin/bash
-rwxr-xr-x 1 root root 1396520 Jan 7 2022 /usr/bin/bash
$ chmod 200 test.sh
$ ls -l test.sh
--w------- 1 test01 test01 5 Dec 9 23:24 test.sh
$ bash test.sh
bash: test.sh: Permission denied
Reserved User IDs and Group IDs
In RHEL, user IDs and group IDs of 1000 and below are reserved for system users and system groups. The usable user IDs and group IDs are specified in the /etc/login.defs file. By default, as shown below, the minimum value for both user IDs and group IDs is 1000.
$ cat /etc/login.defs | grep -e '^UID_MIN' -e '^GID_MIN'
UID_MIN 1000
GID_MIN 1000
Reserved user IDs and group IDs are listed in the following file:
cat /usr/share/doc/setup/uidgid
Incidentally, the range of IDs used for reservations may expand in the future, so it is recommended to assign IDs from 5000 onward. To assign IDs starting from 5000, set UID_MIN and GID_MIN in the aforementioned /etc/login.defs to 5000.
Useful grep Strings
Configuration files can be hard to read when lines are commented out or have blank lines.
Using grep to exclude lines starting with # or blank lines makes configuration files easier to read.
cat <filename> | grep -v '^#' | grep -v '^\n*$'
crontab Timezone Setting
Open the configuration file with crontab -e and add the timezone setting (CRON_TZ=Asia/Tokyo) at the top.
# crontab -l
CRON_TZ=Asia/Tokyo
52 11 * * * touch /root/test.txt
References
File and Directory Operations and Management (Linux Learning) - YouTube
Chapter 4: Managing Users and Groups, Red Hat Enterprise Linux 7 | Red Hat Customer Portal