Search code examples
bashshellmkdir

How to use mkdir -v as defaul mkdir in Linux


In linux ,when I use mkdir -v dir1 ; linux will show me some information like "dir1 create " "dir1 exits" ;

mkdir -v make me fell a "Sense of Security" , i like it . But I want make "mkdir -v " as the default "mkdir" , everytime I use mkdir , it will show me infomation ;

I think this idea beacause everytime i use "mkdir -v", i feel it unconvinient .

I have try some method , like export " alias mkdir="mkdir -v " " in my .bashrc , but it didn't work.

Any easy method to achieve this idea ? Thank you very much !


Solution

  • You will have to define the alias to do this

    The command below will append to your .bashrc and will accomplish the desired result

    echo 'alias mkdir="mkdir -v"' >> ~/.bashrc
    

    Remember to get a new shell or type bash to reload your .bashrc file in your current shell

    If once in a while you don't want this behavior just prefix your command with a \

    \mkdir test
    

    The above will ignore the effect of alias just for this one command.

    Sample run

    $ alias mkdir='mkdir -v'
    $ mkdir test
    mkdir: created directory 'test'
    $ \mkdir test1
    $