Why does the permission expression 653 mean rw- r-x -wx [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I'm not sure whether it is chmod or unmask, but this question is from an exam, where it asks the meaning of 653
I thought 6 means Read(4) + Write(2), 5 means Read(4) plus Execute(1) and that 3 means Write(2) plus Execute(1)
So based on my thoughts, I can't find sense in the answer, as I thought it would be something like rw r+x w+x
Why does the supposedly correct answer have the minus(-) signal instead of the plus(+)?

When permissions are displayed as strings, a dash in a given position means that bit isn't set. And for each of the three octal digits that make up the basic mode, the read bit is always shown in the first position, the write bit is always shown in the second position, and the execute bit is always shown in the third position*. So 0653 appears e.g. in the output of ls -l as rw-r-x-wx.
Plusses and minuses can also be used when setting or unsetting bits with chmod, e.g. chmod u+r (set the read bit in the left-most octal digit), chmod g-w (unset the write bit in the middle octal digit). A plus or minus in this syntax has nothing to do with how it's displayed.
* – Note that the character used to represent the execute bit (x) is sometimes overloaded to show additional information, such as the setuid and setgid bits (s or S) and the tacky bit (t).

Related

How to use dash (-) with unix commands correctly? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I have just noticed that commands:
ps -T
and
ps T
give different results. For instance:
I mean lines 2 and 3 of second output.
Could someone please explain what happens here and how the dash really works in such commands (to be honest I thought options that didn't require an argument could be given without a dash).
Thanks in advance.
what happens here
From man ps with ps from procps:
This version of ps accepts several kinds of options:
1 UNIX options, which may be grouped and must be preceded by a
dash.
2. BSD options, which may be grouped and must not be used
with a dash.
3. GNU long options, which are preceded by two
dashes.
T Select all processes associated with this terminal.
-T Show threads, possibly with SPID column.
Two options with different meaning.
how the dash really works in such commands
Dash represents literally itself. - is a -, the character -. Then the program has logic, if the string that represents the argument passed to the program starts with a - character, then the logic of that program is different, then when the argument does not start with -.
o be honest I thought options that didn't require an argument could be given without a dash
Each and every program has it's own unique semantics and parsing. While there are conventions and standards and options starting with a leading - are the (almost) universal standard, there are exceptions. (For example, "traditional" tar command syntax recognizes options without a -.)
How to use dash (-) with unix commands correctly?
Consult that "command" that you want to run, as it depends on that command how it parses it's arguments.

Meaning of different indicators when using 'ls -F' [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I'm currently studying Bash shell and have encountered command ls -F. I know it ls function is to append indicators to items lists, so to distinguish between different file types. I know that / is appended to directory and * is appended to executable files. But I have checked the manual page on ls command but couldn't find any information on indicator =>#|.
Could someone tell me what they represent? And it would be even better if can inform me where to find this kind of information when in need.
Try info ls, under "What information is listed":
‘-F’
‘--classify’
‘--indicator-style=classify’
Append a character to each file name indicating the file type.
Also, for regular files that are executable, append ‘*’. The file
type indicators are ‘/’ for directories, ‘#’ for symbolic links,
‘|’ for FIFOs, ‘=’ for sockets, ‘>’ for doors, and nothing for
regular files. Do not follow symbolic links listed on the command
line unless the ‘--dereference-command-line’ (‘-H’),
‘--dereference’ (‘-L’), or
‘--dereference-command-line-symlink-to-dir’ options are specified.

Bash Character transformations [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
Here's the latest from my terminal.
E┬$?: N⎺ ⎽┤c▒ °☃┌e ⎺⎼ d☃⎼ec├⎺⎼≤
┴▒±⎼▒┼├#└e⎽⎺⎽:·/de┴e┌⎺⎻└e┼├/⎽⎻┌☃├├e⎼$ └▒┼ └▒⎼▒├▒⎺┼
N⎺ └▒┼┤▒┌ e┼├⎼≤ °⎺⎼ └▒⎼▒├▒⎺┼
See '└▒┼ 7 ┤┼d⎺c┤└e┼├ed' °⎺⎼ ▒e┌⎻ ┬▒e┼ └▒┼┤▒┌ ⎻▒±e⎽ ▒⎼e ┼⎺├ ▒┴▒☃┌▒b┌e↓
┴▒±⎼▒┼├#└e⎽⎺⎽:·/de┴e┌⎺⎻└e┼├/⎽⎻┌☃├├e⎼$ ⎻☃┼± ±⎺±⎺┌e↓c⎺└
PING ±⎺±⎺┌e↓c⎺└ (216↓58↓217↓36) 56(84) b≤├e⎽ ⎺° d▒├▒↓
64 b≤├e⎽ °⎼⎺└ de┼▮3⎽1▮↑☃┼↑°36↓1e1▮▮↓┼e├ (216↓58↓217↓36): ☃c└⎻_⎽e─=1 ├├┌=63 ├☃└e=29↓▮ └⎽
64 b≤├e⎽ °⎼⎺└ de┼▮3⎽1▮↑☃┼↑°36↓1e1▮▮↓┼e├ (216↓58↓217↓36): ☃c└⎻_⎽e─=2 ├├┌=63 ├☃└e=32↓4 └⎽
64 b≤├e⎽ °⎼⎺└ de┼▮3⎽1▮↑☃┼↑°36↓1e1▮▮↓┼e├ (216↓58↓217↓36): ☃c└⎻_⎽e─=3 ├├┌=63 ├☃└e=27↓4 └⎽
64 b≤├e⎽ °⎼⎺└ de┼▮3⎽1▮↑☃┼↑°36↓1e1▮▮↓┼e├ (216↓58↓217↓36): ☃c└⎻_⎽e─=4 ├├┌=63 ├☃└e=25↓9 └⎽
^C
↑↑↑ ±⎺±⎺┌e↓c⎺└ ⎻☃┼± ⎽├▒├☃⎽├☃c⎽ ↑↑↑
4 ⎻▒c┐e├⎽ ├⎼▒┼⎽└☃├├ed← 4 ⎼ece☃┴ed← ▮% ⎻▒c┐e├ ┌⎺⎽⎽← ├☃└e 32▮3└⎽
⎼├├ └☃┼/▒┴±/└▒│/└de┴ = 25↓927/28↓721/32↓426/2↓415 └⎽
┴▒±⎼▒┼├#└e⎽⎺⎽:·/de┴e┌⎺⎻└e┼├/⎽⎻┌☃├├e⎼$ E┴e⎼≤├▒☃┼± ☃⎽ ☃┼ ▒ ┼e┬ ┌▒┼±┤▒±e
E┴e⎼≤├▒☃┼±: c⎺└└▒┼d ┼⎺├ °⎺┤┼d
┴▒±⎼▒┼├#└e⎽⎺⎽:·/de┴e┌⎺⎻└e┼├/⎽⎻┌☃├├e⎼$ ┌⎽
▒⎻⎻↓┘⎽ c⎺┼°☃± D⎺c┐e⎼°☃┌e d⎺c┐e⎼☃≥e↓⎽▒ ┼⎺de_└⎺d┤┌e⎽ ⎻▒c┐▒±e↓┘⎽⎺┼ Re▒d└e↓└d README↓└d
┴▒±⎼▒┼├#└e⎽⎺⎽:·/de┴e┌⎺⎻└e┼├/⎽⎻┌☃├├e⎼$
Now, I'm aware that cating binary files causes all kinds of crazy stuff to happen to your terminal. But I've never asked about it before. I'm trying to track down what exactly would cause this character transformation.
Everything seems to work normally. I can't read the output, but ping commands produce output that behaves as I would expect. ls has the same color coding. custom scripts have the same output (just transformed).
What character sequence would cause this consistent transformation?
typing reset puts me back into sanity.
Am I getting a character transformation via console codes? If so, can I prank friends with this? (alias ls=ls #+some character transformation). Note: I don't want this to have a possibility of ls turning into rm -rf or anything else malicious.
This is caused by the smacs (enter_alt_charset_mode) terminfo sequence being entered into the terminal. It can be switched back with the rmacs (exit_alt_charset_mode) terminfo sequence.
echo "$(tput rmacs)"

what's the meaning of 'c' in result of command "ls -l /dev/tty'? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I'm writing some code to interpret the output of the ls command in Linux (to make it more friendly to newcomers). As one of the test cases, I executed the command 'ls -l /dev/tty', and it returned
crw-rw-rw- 1 root root 5, 0 Apr 15 23:46 /dev/tty
What is the meaning of first char 'c' meaning in first column? I know 'd', 'l', and '-'. Could you list all possible values for this field?
It's a character-based (as opposed to block-based) device file.
Blocked-based devices are anything where it makes sense to transfer data in (surprisingly enough) blocks. By that, I mean things like disks.
Character-based devices (and again, this should come as no surprise) tend to transfer characters at a time. Things like terminals, serial ports, printers and so on.
If you're running a decent Linux distro, that information (plus more than you could probably ever need) can be obtained with the command:
info ls
which contains this little snippet:
The file type is one of the following characters:
- regular file
b block special file
c character special file
C high performance ("contiguous data") file
d directory
D door (Solaris 2.5 and up)
l symbolic link
M off-line ("migrated") file (Cray DMF)
n network special file (HP-UX)
p FIFO (named pipe)
P port (Solaris 10 and up)
s socket
? some other file type
c means it's a character device. Specifically, /dev/tty represents the current console.
That its a character device you are listing
b for block device
The 'c' means it's a character device. tty is a special file representing the 'controlling terminal' for the current process.
Please refer same question here

what is the purpose of the magic number in linux reboots? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
On the Wikipedia page for Linus Torvalds, it states that:
'The Linux kernel's reboot system call accepts their dates of birth (written in hexadecimal) as magic values'.
And documentation for the Linux reboot function shows that it needs two magic numbers, 'magic' and 'magic2' too reboot.
What is the purpose of these magic numbers? Why can't the function operate without them?
Thanks
A quick google of your question yields the answer;
http://www.eeggs.com/items/44291.html
In order to prevent the reboot() system call being
called inadvertently, you must pass it a pair of magic values in the first two parameters. The first magic value is 0xfee1dead. The second magic value
is one of:
$ grep LINUX_REBOOT_MAGIC include/linux/*.h
include/linux/reboot.h:#define LINUX_REBOOT_MAGIC1 0xfee1dead
include/linux/reboot.h:#define LINUX_REBOOT_MAGIC2 672274793
include/linux/reboot.h:#define LINUX_REBOOT_MAGIC2A 85072278
include/linux/reboot.h:#define LINUX_REBOOT_MAGIC2B 369367448
include/linux/reboot.h:#define LINUX_REBOOT_MAGIC2C 537993216
These are dates of significance to Linus; hint
you can use perl to convert them into dates:
$ perl -e 'print localtime(672274793). "\n";'
Sun Apr 21 18:59:53 1991
This is the date that Linus first started writing Linux. The significance of other dates is left as an exercise for the reader ;-)

Resources