Adding command shortcuts to binPull a file from a Docker container?ssh asking for passphrase that doesn't have passphraseCan I cheat the docker run -it session by remapping ctrl+p key?qemu2.6 under dockerIs there a way to make a bootable Linux live USB disk from a Linux docker container?Universal way to check if “docker.for.mac.localhost” DNS name is resolvable?Pass environment variable to docker container CMD that evaluates in containerHow to strace all write calls (to stdout/stderr) from all child processes inside a docker container?docker-compose run --rm slow startupWhat is the best way to run a Docker Container? Cron, or other means? With multiple source files it has to pull from?
List of newcommands used
Point of the Dothraki's attack in GoT S8E3?
A factorization game
Should I dumb down my writing in a foreign country?
Adding command shortcuts to bin
Why did the Apollo 13 crew extend the LM landing gear?
Did the manned NASA capsules rotate during descent?
How to increase the size of the cursor in Lubuntu 19.04?
Why aren't nationalizations in Russia described as socialist?
How to use dependency injection and avoid temporal coupling?
Should homeowners insurance cover the cost of the home?
How to adjust tikz picture so it fits to current size of a table cell?
Does it make sense for a function to return a rvalue reference
What does this wavy downward arrow preceding a piano chord mean?
Floor of Riemann zeta function
Can there be a single technologically advanced nation, in a continent full of non-technologically advanced nations?
Upside-Down Pyramid Addition...REVERSED!
What are the advantages of luxury car brands like Acura/Lexus over their sibling non-luxury brands Honda/Toyota?
How I can I roll a number of non-digital dice to get a random number between 1 and 150?
Wrong answer from DSolve when solving a differential equation
What to use instead of cling film to wrap pastry
I need a disease
Why do people keep telling me that I am a bad photographer?
ZSPL language, anyone heard of it?
Adding command shortcuts to bin
Pull a file from a Docker container?ssh asking for passphrase that doesn't have passphraseCan I cheat the docker run -it session by remapping ctrl+p key?qemu2.6 under dockerIs there a way to make a bootable Linux live USB disk from a Linux docker container?Universal way to check if “docker.for.mac.localhost” DNS name is resolvable?Pass environment variable to docker container CMD that evaluates in containerHow to strace all write calls (to stdout/stderr) from all child processes inside a docker container?docker-compose run --rm slow startupWhat is the best way to run a Docker Container? Cron, or other means? With multiple source files it has to pull from?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Is there any way to add custom commands to /bin?
For example, I use "docker container ls" a lot, and would like to turn this into a shortcut command, like "dcls."
if I add a file named "dcls" to /bin and inside the file, specify the exact command "docker container ls," i assume this wouldn't work.
What is the right way, if there is one, to do something like this?
ubuntu command-line docker
New contributor
add a comment |
Is there any way to add custom commands to /bin?
For example, I use "docker container ls" a lot, and would like to turn this into a shortcut command, like "dcls."
if I add a file named "dcls" to /bin and inside the file, specify the exact command "docker container ls," i assume this wouldn't work.
What is the right way, if there is one, to do something like this?
ubuntu command-line docker
New contributor
add a comment |
Is there any way to add custom commands to /bin?
For example, I use "docker container ls" a lot, and would like to turn this into a shortcut command, like "dcls."
if I add a file named "dcls" to /bin and inside the file, specify the exact command "docker container ls," i assume this wouldn't work.
What is the right way, if there is one, to do something like this?
ubuntu command-line docker
New contributor
Is there any way to add custom commands to /bin?
For example, I use "docker container ls" a lot, and would like to turn this into a shortcut command, like "dcls."
if I add a file named "dcls" to /bin and inside the file, specify the exact command "docker container ls," i assume this wouldn't work.
What is the right way, if there is one, to do something like this?
ubuntu command-line docker
ubuntu command-line docker
New contributor
New contributor
New contributor
asked 1 hour ago
alex067alex067
1083
1083
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
An easy way for a shortcut is to define an alias
alias dcls='docker container ls'
This will execute docker container ls
when you enter dcls
and the command alias
lists your defined aliases. To remove this alias use unalias dcls
.
If you use bash, you can save the alias in your ~/.bashrc
or ~/.bash_aliases
.
If your ~/.bash_aliases
is not read on startup, you can add this line to your ~/.bashrc
:
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
You have to save it in your user's shell startup file~/.bashrc
or~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.
– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
55 mins ago
Really? What an odd server! If you use bash, you can create it usingecho "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with. ~/.bashrc
or logout and login again.
– Freddy
49 mins ago
Cheers for your help, got it working!
– alex067
48 mins ago
add a comment |
Actually, what you describe would work, with a few notes:
- You could simply put
docker container ls
into a file called/bin/dcls
.
But the behavior of that can be a little complicated.
It’s a little more reliable to begin the file with a line called a “shebang”,
so the file would look like#!/bin/sh
which specifies that the file is a shell script.
docker container ls - Before you can run the command,
you must make the file executable with a command likechmod +x /bin/dcls
You probably need to be root to do this (i.e., run it withsudo
). Follow the above two steps and you will be able to type
dcls
and it will dodocker container ls
.
But, if you typedcls -l foo
, it will still dodocker container ls
.
If you want it to dodocker container ls -l foo
,
you should change the script to say#!/bin/sh
docker container ls "$@"
which specifies that any arguments that you type on thedcls
command line
should be passed along to thedocker container ls
command.Naturally, there are more complicated things
you can do with command-line arguments.
For a mapping of one simple command → one simple command,
that doesn’t need to be shared with other users,
it’s simpler to define an alias (as Freddy suggested),
or a shell function.
More complicated functions are often written as scripts;
i.e., text files that contain commands.
But, if you don’t need to share it with other users,
it’s more common to use a private bin
directory.
$ cd # (to your home directory)Then copy
$ mkdir bin
dcls
to $HOME/bin
,and add
export PATH="$HOME/bin:$PATH"to your
~/.bashrc
.Also, it’s common to put personal scripts into /usr/local/bin
,
and leave /bin
for the programs that came with the system.
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
3 mins ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
alex067 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f516870%2fadding-command-shortcuts-to-bin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
An easy way for a shortcut is to define an alias
alias dcls='docker container ls'
This will execute docker container ls
when you enter dcls
and the command alias
lists your defined aliases. To remove this alias use unalias dcls
.
If you use bash, you can save the alias in your ~/.bashrc
or ~/.bash_aliases
.
If your ~/.bash_aliases
is not read on startup, you can add this line to your ~/.bashrc
:
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
You have to save it in your user's shell startup file~/.bashrc
or~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.
– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
55 mins ago
Really? What an odd server! If you use bash, you can create it usingecho "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with. ~/.bashrc
or logout and login again.
– Freddy
49 mins ago
Cheers for your help, got it working!
– alex067
48 mins ago
add a comment |
An easy way for a shortcut is to define an alias
alias dcls='docker container ls'
This will execute docker container ls
when you enter dcls
and the command alias
lists your defined aliases. To remove this alias use unalias dcls
.
If you use bash, you can save the alias in your ~/.bashrc
or ~/.bash_aliases
.
If your ~/.bash_aliases
is not read on startup, you can add this line to your ~/.bashrc
:
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
You have to save it in your user's shell startup file~/.bashrc
or~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.
– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
55 mins ago
Really? What an odd server! If you use bash, you can create it usingecho "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with. ~/.bashrc
or logout and login again.
– Freddy
49 mins ago
Cheers for your help, got it working!
– alex067
48 mins ago
add a comment |
An easy way for a shortcut is to define an alias
alias dcls='docker container ls'
This will execute docker container ls
when you enter dcls
and the command alias
lists your defined aliases. To remove this alias use unalias dcls
.
If you use bash, you can save the alias in your ~/.bashrc
or ~/.bash_aliases
.
If your ~/.bash_aliases
is not read on startup, you can add this line to your ~/.bashrc
:
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
An easy way for a shortcut is to define an alias
alias dcls='docker container ls'
This will execute docker container ls
when you enter dcls
and the command alias
lists your defined aliases. To remove this alias use unalias dcls
.
If you use bash, you can save the alias in your ~/.bashrc
or ~/.bash_aliases
.
If your ~/.bash_aliases
is not read on startup, you can add this line to your ~/.bashrc
:
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
answered 1 hour ago
FreddyFreddy
2,525312
2,525312
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
You have to save it in your user's shell startup file~/.bashrc
or~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.
– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
55 mins ago
Really? What an odd server! If you use bash, you can create it usingecho "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with. ~/.bashrc
or logout and login again.
– Freddy
49 mins ago
Cheers for your help, got it working!
– alex067
48 mins ago
add a comment |
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
You have to save it in your user's shell startup file~/.bashrc
or~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.
– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
55 mins ago
Really? What an odd server! If you use bash, you can create it usingecho "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with. ~/.bashrc
or logout and login again.
– Freddy
49 mins ago
Cheers for your help, got it working!
– alex067
48 mins ago
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
Thanks Freddy! Will I have to create this alias every time the server restarts? Or is it bounded to my user profile?
– alex067
1 hour ago
1
1
You have to save it in your user's shell startup file
~/.bashrc
or ~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.– Freddy
1 hour ago
You have to save it in your user's shell startup file
~/.bashrc
or ~/.profile
or ... If you don't save the alias it is lost when you logout or close the terminal.– Freddy
1 hour ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
55 mins ago
Thanks again. What if we dont have .bashrc or .profile in our ~ folder?
– alex067
55 mins ago
Really? What an odd server! If you use bash, you can create it using
echo "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with . ~/.bashrc
or logout and login again.– Freddy
49 mins ago
Really? What an odd server! If you use bash, you can create it using
echo "alias dcls='docker container ls'" >> ~/.bashrc
, then source it with . ~/.bashrc
or logout and login again.– Freddy
49 mins ago
Cheers for your help, got it working!
– alex067
48 mins ago
Cheers for your help, got it working!
– alex067
48 mins ago
add a comment |
Actually, what you describe would work, with a few notes:
- You could simply put
docker container ls
into a file called/bin/dcls
.
But the behavior of that can be a little complicated.
It’s a little more reliable to begin the file with a line called a “shebang”,
so the file would look like#!/bin/sh
which specifies that the file is a shell script.
docker container ls - Before you can run the command,
you must make the file executable with a command likechmod +x /bin/dcls
You probably need to be root to do this (i.e., run it withsudo
). Follow the above two steps and you will be able to type
dcls
and it will dodocker container ls
.
But, if you typedcls -l foo
, it will still dodocker container ls
.
If you want it to dodocker container ls -l foo
,
you should change the script to say#!/bin/sh
docker container ls "$@"
which specifies that any arguments that you type on thedcls
command line
should be passed along to thedocker container ls
command.Naturally, there are more complicated things
you can do with command-line arguments.
For a mapping of one simple command → one simple command,
that doesn’t need to be shared with other users,
it’s simpler to define an alias (as Freddy suggested),
or a shell function.
More complicated functions are often written as scripts;
i.e., text files that contain commands.
But, if you don’t need to share it with other users,
it’s more common to use a private bin
directory.
$ cd # (to your home directory)Then copy
$ mkdir bin
dcls
to $HOME/bin
,and add
export PATH="$HOME/bin:$PATH"to your
~/.bashrc
.Also, it’s common to put personal scripts into /usr/local/bin
,
and leave /bin
for the programs that came with the system.
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
3 mins ago
add a comment |
Actually, what you describe would work, with a few notes:
- You could simply put
docker container ls
into a file called/bin/dcls
.
But the behavior of that can be a little complicated.
It’s a little more reliable to begin the file with a line called a “shebang”,
so the file would look like#!/bin/sh
which specifies that the file is a shell script.
docker container ls - Before you can run the command,
you must make the file executable with a command likechmod +x /bin/dcls
You probably need to be root to do this (i.e., run it withsudo
). Follow the above two steps and you will be able to type
dcls
and it will dodocker container ls
.
But, if you typedcls -l foo
, it will still dodocker container ls
.
If you want it to dodocker container ls -l foo
,
you should change the script to say#!/bin/sh
docker container ls "$@"
which specifies that any arguments that you type on thedcls
command line
should be passed along to thedocker container ls
command.Naturally, there are more complicated things
you can do with command-line arguments.
For a mapping of one simple command → one simple command,
that doesn’t need to be shared with other users,
it’s simpler to define an alias (as Freddy suggested),
or a shell function.
More complicated functions are often written as scripts;
i.e., text files that contain commands.
But, if you don’t need to share it with other users,
it’s more common to use a private bin
directory.
$ cd # (to your home directory)Then copy
$ mkdir bin
dcls
to $HOME/bin
,and add
export PATH="$HOME/bin:$PATH"to your
~/.bashrc
.Also, it’s common to put personal scripts into /usr/local/bin
,
and leave /bin
for the programs that came with the system.
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
3 mins ago
add a comment |
Actually, what you describe would work, with a few notes:
- You could simply put
docker container ls
into a file called/bin/dcls
.
But the behavior of that can be a little complicated.
It’s a little more reliable to begin the file with a line called a “shebang”,
so the file would look like#!/bin/sh
which specifies that the file is a shell script.
docker container ls - Before you can run the command,
you must make the file executable with a command likechmod +x /bin/dcls
You probably need to be root to do this (i.e., run it withsudo
). Follow the above two steps and you will be able to type
dcls
and it will dodocker container ls
.
But, if you typedcls -l foo
, it will still dodocker container ls
.
If you want it to dodocker container ls -l foo
,
you should change the script to say#!/bin/sh
docker container ls "$@"
which specifies that any arguments that you type on thedcls
command line
should be passed along to thedocker container ls
command.Naturally, there are more complicated things
you can do with command-line arguments.
For a mapping of one simple command → one simple command,
that doesn’t need to be shared with other users,
it’s simpler to define an alias (as Freddy suggested),
or a shell function.
More complicated functions are often written as scripts;
i.e., text files that contain commands.
But, if you don’t need to share it with other users,
it’s more common to use a private bin
directory.
$ cd # (to your home directory)Then copy
$ mkdir bin
dcls
to $HOME/bin
,and add
export PATH="$HOME/bin:$PATH"to your
~/.bashrc
.Also, it’s common to put personal scripts into /usr/local/bin
,
and leave /bin
for the programs that came with the system.
Actually, what you describe would work, with a few notes:
- You could simply put
docker container ls
into a file called/bin/dcls
.
But the behavior of that can be a little complicated.
It’s a little more reliable to begin the file with a line called a “shebang”,
so the file would look like#!/bin/sh
which specifies that the file is a shell script.
docker container ls - Before you can run the command,
you must make the file executable with a command likechmod +x /bin/dcls
You probably need to be root to do this (i.e., run it withsudo
). Follow the above two steps and you will be able to type
dcls
and it will dodocker container ls
.
But, if you typedcls -l foo
, it will still dodocker container ls
.
If you want it to dodocker container ls -l foo
,
you should change the script to say#!/bin/sh
docker container ls "$@"
which specifies that any arguments that you type on thedcls
command line
should be passed along to thedocker container ls
command.Naturally, there are more complicated things
you can do with command-line arguments.
For a mapping of one simple command → one simple command,
that doesn’t need to be shared with other users,
it’s simpler to define an alias (as Freddy suggested),
or a shell function.
More complicated functions are often written as scripts;
i.e., text files that contain commands.
But, if you don’t need to share it with other users,
it’s more common to use a private bin
directory.
$ cd # (to your home directory)Then copy
$ mkdir bin
dcls
to $HOME/bin
,and add
export PATH="$HOME/bin:$PATH"to your
~/.bashrc
.Also, it’s common to put personal scripts into /usr/local/bin
,
and leave /bin
for the programs that came with the system.
answered 18 mins ago
G-ManG-Man
14k93871
14k93871
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
3 mins ago
add a comment |
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
3 mins ago
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
3 mins ago
Great answer. If I add it to bin like I mentioned, that would affect all users correct?
– alex067
3 mins ago
add a comment |
alex067 is a new contributor. Be nice, and check out our Code of Conduct.
alex067 is a new contributor. Be nice, and check out our Code of Conduct.
alex067 is a new contributor. Be nice, and check out our Code of Conduct.
alex067 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f516870%2fadding-command-shortcuts-to-bin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown