DEV Community

Cover image for Working With Shell

Working With Shell

Script Koder on September 12, 2024

What is a shell? Linux shell is a program that allows text-based interaction between the user and the computer Types of shel...
Collapse
 
jimmymcbride profile image
Jimmy McBride

Would love to see something about pushd and popd in addition to cd. They can be very handy tools when you changing directories a lot and need to make a quick escape to where you've previously been! :)

Can't wait to see more!

Collapse
 
nerdflash28 profile image
Script Koder

Thanks for your response, i'll keep updating this page.

Collapse
 
fnabinash profile image
Abinash Sahoo

Why not create a series on Linux and bash covering from basics to advanced topics? πŸ€”πŸ€”

Thread Thread
 
nerdflash28 profile image
Script Koder

sure, i'm working on it

Collapse
 
kubernetic profile image
BC

I think an important concept is also where a user's shell is defined.

A user's shell is typically setup when the user is added to the system. Often /bin/bash is set as a default, but macOS now sets /bin/zsh as the default shell for users.

A user could find their default shell by viewing the /etc/passwd file. For example,

root:x:0:0:root:/root:/bin/bash
games:x:12:100:games:/usr/games:/sbin/nologin
Enter fullscreen mode Exit fullscreen mode

In the above example root's default shell is set to the Bash shell. While the games user actually has been set to a nologin shell, preventing anyone from logging into the user. This has certain uses for non-interactive user sessions. We have other shell options that we can use as well. There are lots of varieties and it depends on your OS, or what the administrator has set at account creation.

There are different commands to modify a user's shell. But one way you can do this is with the usermod command:

usermod -s /bin/bash USER

If you want to find a list of available shells on your system, try this command:
cat /etc/shells

Collapse
 
pauljlucas profile image
Paul J. Lucas

There's no such thing as a Linux shell. There are only various shells, e.g., bash, tcsh, zsh, etc. You can use exactly the same shells on FreeBSD, macOS, and others as you can on Linux.

Collapse
 
nerdflash28 profile image
Script Koder • Edited

@pauljlucas Yeah, you are correct mate, thanks for the help, i've updated the title accordingly.

Collapse
 
pauljlucas profile image
Paul J. Lucas

You might want to reconsider the banner image and #linux tag as well.

Collapse
 
pauljlucas profile image
Paul J. Lucas

You still mention "Linux shell....". You ought to replace that with "A shell...."

Collapse
 
manchicken profile image
Mike Stemle

I’m glad to see folks still talking about the terminal. That said, none of this is bash-specific. These will all work in a variety of shells, and I hope folks find whatever shell they prefer and have a great time in the shell.

Collapse
 
pauljlucas profile image
Paul J. Lucas

You mention commands, but never once mention the PATH environment variable or explain that commands like mkdir "live" in certain directories and the way commands work is that the shell searches PATH for a matching command.

Collapse
 
kmsaifullah profile image
Khaled Md Saifullah

In my opinion "how bash works" is also an important topic for a beginners, Don't you think so?

Collapse
 
nerdflash28 profile image
Script Koder

Beginners with no experience with bash, see the black screen and don't know what to write on it.

From my Teaching experience, they are more interested in, How to use it.
not "How it works".

I hope you understood my point, sir.

Thanks for your Feedback though