What is difference between these command: I used cd $HOME/directory/test/
before running each lines:
cd ~
cd /
cd ~/
cd -
cd --
cd /.
cd $HOME
cd $USR
cd
And all of these do the same behavior. What is difference?
command line
What is difference between these command: I used cd $HOME/directory/test/
before running each lines:
cd ~
cd /
cd ~/
cd -
cd --
cd /.
cd $HOME
cd $USR
cd
And all of these do the same behavior. What is difference?
dir
and ls
are part of coreutils
and dir
is almost the same as ls
, just with different default options.
The GNU Core Utilities are the basic file, shell and text manipulation utilities of the GNU operating system. These are the core utilities which are expected to exist on every operating system.
info dir
says:
dir
is equivalent tols -C -b
; that is, by default files are listed in columns, sorted vertically, and special characters are represented by backslash escape sequences.
Oh and there is also vdir
! info vdir
says:
vdir
is equivalent tols -l -b
; that is, by default files are listed in long format and special characters are represented by backslash escape sequences.
Most likely dir
exists for backwards compatibility or due to historical reasons.
Short answer:
Long answer:
Console and terminal are closely related. Originally, they meant a piece of equipment through which you could interact with a computer: in the early days of unix, that meant a teleprinter-style device resembling a typewriter, sometimes called a teletypewriter, or “tty” in shorthand. The name “terminal” came from the electronic point of view, and the name “console” from the furniture point of view. Very early in unix history, electronic keyboards and displays became the norm for terminals.
In unix terminology, a terminal is a particular kind of device file which implements a number of additional commands (ioctls) beyond read and write. Some terminals are provided by the kernel on behalf of a hardware device, for example with the input coming from the keyboard and the output going to a text mode screen, or with the input and output transmitted over a serial line. Other terminals, sometimes called pseudo-terminals or pseudo-ttys, are provided (through a thin kernel layer) by programs called terminal emulators. Some types of terminal emulators include:
The word terminal can also have a more traditional meaning of a device through which one interacts with a computer, typically with a keyboard and display. For example an X terminal is a kind of thin client, a special-purpose computer whose only purpose is to drive a keyboard, display, mouse and occasionally other human interaction peripherals, with the actual applications running on another, more powerful computer.
A console is generally a terminal in the physical sense that is by some definition the primary terminal directly connected to a machine. The console appears to the operating system as a (kernel-implemented) terminals. On some systems, such as Linux and FreeBSD, the console appears as several terminals (ttys) (special key combinations switch between these terminals); just to confuse matters, the name given to each particular terminal can be “console”, ”virtual console”, ”virtual terminal”, and other variations.
See also Why is a Virtual Terminal “virtual”, and what/why/where is the “real” Terminal?.
A command line is an interface where the user types a command (which is expressed as a sequence of characters — typically a command name followed by some parameters) and presses the Return key to execute that command.
A shell is the primary interface that users see when they log in, whose primary purpose is to start other programs. (I don't know whether the original metaphor is that the shell is the home environment for the user, or that the shell is what other programs are running in.)
In unix circles, shell has specialized to mean a command-line shell, centered around entering the name of the application one wants to start, followed by the names of files or other objects that the application should act on, and pressing the Enter key. Other types of environments (with the notable recent exception of Gnome Shell) usually don't use the word “shell”; for example, window systems involve “window managers” and “desktop environments”, not a “shell”.
There are many different unix shells. Ubuntu's default shell is Bash (like most other Linux distributions). Popular alternatives include zsh (which emphasizes power and customizability) and fish (which emphasizes simplicity).
Command-line shells include flow control constructs to combine commands. In addition to typing commands at an interactive prompt, users can write scripts. The most common shells have a common syntax based on the Bourne_shell. When discussing “shell programming”, the shell is almost always implied to be a Bourne-style shell. Some shells that are often used for scripting but lack advanced interactive features include the Korn shell (ksh) and many ash variants. Pretty much any Unix-like system has a Bourne-style shell installed as /bin/sh
, usually ash, ksh or bash. On Ubuntu, /bin/sh
is Dash, an ash variant (chosen because it is faster and uses less memory than bash).
In unix system administration, a user's shell is the program that is invoked when they log in. Normal user accounts have a command-line shell, but users with restricted access may have a restricted shell or some other specific command (e.g. for file-transfer-only accounts).
The division of labor between the terminal and the shell is not completely obvious. Here are their main tasks.
\e[D
). The shell converts control sequences into commands (e.g. \e[D
→ backward-char
).M-x shell
in Emacs.foo
”, “switch the foreground color to green”, “move the cursor to the next line”, etc. The terminal acts on these instructions.Recycled from Unix & Linux
Best Answer
The simple command
cd <dir>
which changes directory to<dir>
.~
indicates$HOME
directory/
indicates the root directory~/
indicates the$HOME
directory as well. The only difference is that it explicitly shows it's a directory (the trailing slash).cd ~/
andcd
andcd ~
andcd $HOME
all do exactly the same thing.cd -
Changes the working directory to the previous working directory.These special symbols "." (dot) and ".." (dot dot)[Relative Parameters]:
The "." symbol refers to the current directory and the ".." symbol refers to the current directory's parent directory.
$USER
and$HOME
are Environment-Variables$USER
= The name of the currently logged-in user. This variable is set by the system. You probably shouldn't change its value manually. (ex:myuser1)$HOME
= The location of the currently logged-in user's home directory.(ex: /home/myuser1)Recommended to use
cd "$HOME"
orcd "$USER"
so-thatcd
gets proper input in case of space, etc.