# are FreeBSD commands the same of the orginal UNIX from AT&T



## Ahmed El Gohary (Jan 12, 2020)

well, guys, I'm a little bored of GUI and I want to dig into commands more.
I've used Linux before and I know basics command but I want to learn the original commands of UNIX so I wondered as it's not easy if impossible task to get AT&T Unix and run it on my modern Intel Xeon HP Z workstation but I can get FreeBSD running, so my point is, are BSD/UNIX using the same commands and if I learned FreeBSD even for curiosity. will I be able to use any UNIX even in a terminal remote session?


----------



## kpedersen (Jan 12, 2020)

The commands on a UNIX system are dictated by a standard called POSIX

(https://en.wikipedia.org/wiki/POSIX)

So not only will the standard commands (and their arguments) work on other UNIX operating systems, but all systems that adhere to POSIX (Linux, BSD, QNX, z/OS with POSIX layer, Plan 9 APE, Microsoft SFU/Interix).

So FreeBSD project specific programs (*pkg*, *systemctl*) are not under POSIX and are fairly unique, but *sh*, *awk*, *sed*, *ls*, etc are all consistent.

A list of these can be found here:


			Index of /onlinepubs/009695399/utilities
		


Note that some operating systems (Even those based on UNIX) do not always adhere to POSIX perfectly. In particular the GNU grep utility on Linux has some differences to arguments (and some extensions).


----------



## Ahmed El Gohary (Jan 12, 2020)

kpedersen said:


> The commands on a UNIX system are dictated by a standard called POSIX
> 
> (https://en.wikipedia.org/wiki/POSIX)
> 
> ...


this means that if I mastered FreeBSD commands i'll be able to dig around any UNIX or UNIX like OS


----------



## blackhaz (Jan 12, 2020)

You probably won't feel right at home but yes, you'll be much more familiar with the whole Unix family.


----------



## Phishfry (Jan 12, 2020)

Ahmed El Gohary said:


> this means that if I mastered FreeBSD commands i'll be able to dig around any UNIX or UNIX like OS


Please be advised that depending on what FreeBSD shell you use will determines how some of the basic POSIX compliant programs work.


----------



## kpedersen (Jan 12, 2020)

Ahmed El Gohary said:


> this means that if I mastered FreeBSD commands i'll be able to dig around any UNIX or UNIX like OS



In essence, yes. At least, a lot more familiar than learning the Windows / MSDOS command line for example.

But there are some "quality of life" differences. For example I take for granted the <tab> to auto complete key. This allows me to perform tasks much faster than with a GUI. Unfortunately on the old UNIX (or Plan 9), this does not exist.


----------



## Ahmed El Gohary (Jan 12, 2020)

Phishfry said:


> Please be advised that depending on what FreeBSD shell you use will determines how some of the basic POSIX compliant programs work.



what is the best shell as it's a bit messy in my head i don't know which one should i use sh vs csh vs tcsh i don't know (


----------



## memreflect (Jan 12, 2020)

Ahmed El Gohary said:


> what is the best shell as it's a bit messy in my head i don't know which one should i use sh vs csh vs tcsh i don't know (


If you're going to learn a shell, sh(1) is a good choice as it is highly portable. If you want a more featureful shell, tcsh(1) is the better choice. On some systems, csh and tcsh may be different shells, but on FreeBSD, they're the same.


----------



## Ahmed El Gohary (Jan 12, 2020)

kpedersen said:


> In essence, yes. At least, a lot more familiar than learning the Windows / MSDOS command line for example.
> 
> But there are some "quality of life" differences. For example I take for granted the <tab> to auto complete key. This allows me to perform tasks much faster than with a GUI. Unfortunately on the old UNIX (or Plan 9), this does not exist.


i'm ready to learn it but don't know from where to start the write shell as the on'y one i've used in my entire life is bash in macOS "for creating a bootable installer and in linux 
so which one should i choose during the installation process sh or csh or tcsh 
and i if i entered a certain command how on earth i could save and exit it to the main shell for ex:
when i use chpass after i finish i can't get out of it or save the changes i performed


----------



## Ahmed El Gohary (Jan 12, 2020)

memreflect said:


> If you're going to learn a shell, sh(1) is a good choice as it is highly portable.  If you want a more featureful shell, tcsh(1) is the better choice.  On some systems, `csh` and `tcsh` may be different shells, but on FreeBSD, they're the same.


i'll start with sh as i found it online it's the original shell for unix .
but how can i get out of command after i executed for ex:
i pressed chpass it took me to a new stuff to edit after i finish how i save and return to the main shell again?


----------



## memreflect (Jan 12, 2020)

Ahmed El Gohary said:


> i'll start with sh as i found it online it's the original shell for unix .


I should clarify that I don't have a lot of experience with tcsh (or any other csh).  The one advantage I've found aside from portability in my limited experience that makes `sh` better than `tcsh` for scripting is the `$@` variable when I'm writing a shell script that passes arguments to another command, script, or even a function in the same script.  I think tcsh only has the equivalent of `$*`, which makes passing arguments containing spaces, tabs, or newlines to another command/script/function difficult or even impossible.  That said, tcsh is good enough as an interactive shell, even if I prefer using something else like ksh93, fish, or es (ksh93 being the only sh-compatible one).



Ahmed El Gohary said:


> but how can i get out of command after i executed for ex:
> i pressed chpass it took me to a new stuff to edit after i finish how i save and return to the main shell again?



If you have a list of key combinations at the top of the screen, you're using ee(1), and you'd use `Esc` to activate the main menu and follow the on-screen prompts to leave the editor.
If you're in vi, press the `Esc` key to ensure you're in Normal mode, followed by `:` to enter an ex command.  At this point, you can type `wq` to write the file and quit the editor in one command or `q!` if you want to quit without saving your changes.
If you're in ex (you only have a `:` prompt), just type `wq` or `q!` as stated above.  If you're in ex without the `:` prompt, you're in Insert mode.  Type `.` on a line by itself to return to Command mode, followed by `wq` or `q!`.


----------



## Ahmed El Gohary (Jan 12, 2020)

memreflect said:


> I should clarify that I don't have a lot of experience with tcsh (or any other csh).  The one advantage I've found aside from portability in my limited experience that makes `sh` better than `tcsh` for scripting is the `$@` variable when I'm writing a shell script that passes arguments to another command, script, or even a function in the same script.  I think tcsh only has the equivalent of `$*`, which makes passing arguments containing spaces, tabs, or newlines to another command/script/function difficult or even impossible.  That said, tcsh is good enough as an interactive shell, even if I prefer using something else like ksh93, fish, or es (ksh93 being the only sh-compatible one).
> 
> 
> 
> ...


for ex i can't get out of man command


----------



## bjs (Jan 12, 2020)

Press the "q" key...


----------



## memreflect (Jan 12, 2020)

Ahmed El Gohary said:


> for ex i can't get out of man command
> View attachment 7397


That's because man(1) uses a pager.  It probably used less(1), but some systems use `more` instead.  Either way, simply press 'q' to quit.  While `less` is running, pressing 'h' displays the keybindings if you need help figuring out what keys to press.


----------

