What is special about /dev/tty?

The ‘c’ means it’s a character device. tty is a special file representing the ‘controlling terminal’ for the current process. Character Devices Unix supports ‘device files’, which aren’t really files at all, but file-like access points to hardware devices. A ‘character’ device is one which is interfaced byte-by-byte (as opposed to buffered IO). TTY /dev/tty …

Read more

Reasoning behind C sockets sockaddr and sockaddr_storage

I’m looking at functions such as connect() and bind() in C sockets and notice that they take a pointer to a sockaddr struct. I’ve been reading and to make your application AF-Independent, it is useful to use the sockaddr_storage struct pointer and cast it to a sockaddr pointer because of all the extra space it …

Read more

What generates the “text file busy” message in Unix?

This error means you are trying to modify an executable while it is executing. The “Text” here refers to the fact that the file being modified is the text segment for a running program. Use lsof to check what other processes are using it. You can use kill command to kill it if needed.

What do the dup() and dup2() systems really do?

Both make a new file descriptor corresponding to an existing open file description. Most properties between the old and new fd (like position) are shared; the only property I can think of that’s not shared is the close-on-exec flag. The difference between dup and dup2 is that dup assigns the lowest available file descriptor number, …

Read more

Display current path in terminal only

If you just want to get the information of current directory, you can type: and you don’t need to use the Nautilus, or you can use a teamviewer software to remote connect to the computer, you can get everything you want.