Shell which command




















You will use a program called chsh. There is a interactive method and non-interactive method. Type the following into your terminal:. This results in a brief dialog in which the user is prompted first for their password and then for the full path of the desired new shell. Caution should be exercised when changing one's default shell because it is possible to make an error that only the root user i.

In particular, it is important to first test the shell temporarily in the current session and then to make certain that a valid shell name is being entered when making the permanent change. However, you need to log out and back in for the change to take effect. You should see it shows the new shell. You may not want to know the current shell's name e. Ubuntu Community Ask! Sign up to join this community. The best answers are voted up and rise to the top.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. How do I check which shell I am using? Ask Question.

Asked 6 years, 8 months ago. Active 4 months ago. Viewed k times. I read that terminal is nothing but shell, and Unix provides different flavors of shells: Bourne shell sh C shell csh TC shell tcsh Korn shell ksh Bourne Again shell bash Questions: When I open a terminal window, which shell is opened by default? How do I check how many shells are installed?

How do I change the shell used from my account? Improve this question. Shell Commands Here is a summary of some of the commands available. Logging out Command Description logout log out of a Linux terminal Note, on a Linux workstation you will need to exit the Desktop Environment instead.

Files and Directories These commands allow you to create directories and handle files. Command Description cat concatenate and print data lpr spool file for line printing cd change current directory lprm, cancel remove jobs from line printer queue chgrp change file group ls list and generate statistics for files chmod change file mode mkdir make a new directory cp copy file data more, page display file data at your terminal.

Command Description file determine file type mv move or rename files find find files pwd print working directory grep search file for regular expression rm, rmdir remove unlink files or directories head give first few lines tail print last lines from file just text justification program touch update access and modification times of a file lpq spool queue examination program.

Command Description awk pattern scanning and processing language perl data manipulation language cmp compare the contents of two files paste merge file data comm compare sorted data sed stream text editor cut cut out selected fields of each line of a file sort sort file data diff differential file comparator.

Command Description split split file into smaller files expand, unexpand expand tabs to spaces, and vice versa tr translate characters gawk pattern scanning and processing language uniq report repeated lines in a file join join files on some common field look find lines in sorted data wc count words, lines, and characters.

Command Description gzip compress files zmore file perusal filter for crt viewing of compressed text uncompress uncompress files. Command Description zcat cat a compressed file gunzip uncompress gzipped files zcmp, zdiff compare compressed files. Command Description apropos locate commands by keyword lookup man displays manual pages online. Command Description kill send a signal to a process uptime display system status last show last logins of users users print names of logged in users lun list user names or login ID vmstat report virtual memory statistics netstat show network status w show what logged in users are doing who list logged in users printenv display value of a shell variable.

Command Description write send a message to another local user wall send a message to all local users. Command Description pine vdu-based mail utility mail simple send or read mail program thunderbird GUI mail handling tool on Linux.

The addition of that :; above forces perl to invoke a shell there. By using which , you wouldn't have to use that trick. The reasons why one may not want to use which have already been explained, but here are a few examples on a few systems where which actually fails.

On Bourne-like shells, we're comparing the output of which with the output of type type being a shell builtin, it's meant to be the ground truth, as it's the shell telling us how it would invoke a command.

The reason being that which only reports about executables, and sometimes about aliases though not always the ones of your shell , not functions. Another obvious case is builtins or keywords, as which being an external command has no way to know which builtins your shell have and some shells like zsh , bash or ksh can load builtins dynamically :. The aliases it will report are the ones defined there regardless of the aliases you currently have defined and regardless of the shell you're actually using.

On that system, there's an alias defined system-wide that wraps the GNU which command. In my case, sh being dash but it's the same when it's bash.

Which is why which gets it wrong above since it's using dash 's default PATH which is different from ksh93 's. The one Chris is referring to in his answer :. One thing which from my quick skim it seems that Stephane didn't mention is that which has no idea about your shell's path hash table.

This has the effect that it might return a result which is not representative of what actually is run, which makes it ineffective in debugging. Recently I found this post and was quite surprised -- I have been doing this wrong all the time? But then I checked all the answers and didn't find any reason to drop which entirely. I think that you should use any tool as long as it covers all your needs. I have never heard that. Please provide specific examples.

I would worry about your linux distribution and installed software packages, as to that is from where which comes from! It also provides these other files. Release notes can easily be found back to v2. Not sure what the point or goal of this was, it certainly was not answered in that lengthy thing upvoted times. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Learn more. Why not use "which"? What to use then? Ask Question. Asked 8 years, 3 months ago. Active 4 months ago. Viewed 70k times. We often hear that which should be avoided. What should we use instead? Improve this question. I think most arguments against using which are assuming an interactive shell context. Most answers and reasons against which deal with aliases, builtins and functions, which in most real-world portable shell scripts are just of academic interest.

Writing code in comment? Please use ide. Load Comments. What's New. Most popular in Linux-Unix. More related articles in Linux-Unix.



0コメント

  • 1000 / 1000