Facebook Twitter Instagram
    Techtown
    • General
    • Linux
      • Linux Commands
      • Debian
      • Ubuntu
      • Linux Mint
      • Centos
      • OpenSUSE
      • Fedora
    • Text Editors
      • Notepad++
      • Sublime Text
    • Resources
      • Books
    • Write for Us
    Facebook Twitter Instagram
    Techtown
    Home » Why you get cp: omitting directory error in Linux and how to solve
    Linux

    Why you get cp: omitting directory error in Linux and how to solve

    By SandiApril 19, 2021Updated:April 19, 2021No Comments2 Mins Read
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Linux cp command allows you to copy files and directories. By default, it works on file only. When you try to copy a directory. You get the below error on the terminal.

    cp: -r not specified; omitting directory 

    Let’s understand why you get this error in Linux and find out the solution.

    First, let’s reproduce cp: omitting directory error

    Let’s copy a file from src_file.txt to /home/atechtown/dest_dir folder.

    cp src_file.txt /home/atechtown/dest_dir

    This works fine for files.

    Now, let’s run the command for the directory and see what happens. Copy a directory from src_dir to desk_dir.

    cp src_dir desk_dir
    cp: -r not specified; omitting directory 'src_dir'

    What is wrong with the copy command? Why the error message cp omitting directory?

    cp omitting directory error solution

    cp: omitting directory error tells that directories are not copied as the cp command by default works on the files only. Simply, use the cp command with  -r or -R (recursive) as an argument to resolve cp: omitting directory error.

    This is what this option says,

     -R, -r, --recursive
    copy directories recursively

    So -r or -R option allows you to copy directories/subdirectories recursively.

    Now let’s run the copy command with the – r option.

    cp -r src_dir dest_dir

    or

    cp -R src_dir dest_dir

    Now you can see the command worked fine and directories along with contents are also copied.

    Summary

    Linux cp command is very useful and powerful. By default, it works on files only. You need to use the -r or -R option to copy directories otherwise, you will get omitting directory error. This solution should work on any Unix alike and Linux Distros -Ubuntu, Redhat, Fedora or OpenSuse, CentOS, et

    Refer to this discussion on Askubuntu and StackOverflow for additional details.

    I hope you found this article helpful. Please share and subscribe.

    linux commands Ubuntu
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to Install Notepad++ on Ubuntu 20.04/18.04 LTS
    Next Article Which shell am I using?
    Sandi
    • Website
    • Twitter

    I am Oracle Certified Associate(OCA) working in Oracle Domain since last 15 Years. Started this blog to share knowledge about different Technologies mostly focussing on Oracle.

    Related Posts

    How to Open a Terminal in Linux Mint

    May 24, 2022

    How to Restart Ubuntu From the Terminal

    May 23, 2022

    How to Install Zoom on openSUSE

    May 22, 2022
    Add A Comment

    Comments are closed.

    Recent Posts
    • How to Open a Terminal in Linux Mint
    • How to Restart Ubuntu From the Terminal
    • How to Install Zoom on openSUSE
    • How to Install xArchiver on Debian 11
    • How to Install UNRAR on Fedora 35/34/33/32
    Affiliate Disclosure
    This website contains Affiliate Links. We get small commission for purchases made through affiliate links (at no extra cost to you)
    Facebook Twitter Instagram Pinterest
    • Debian
    • Ubuntu
    • Mint
    • Fedora
    • CentOS
    • openSUSE
    • Chrome
    • XAMPP
    • Forums
    • Notepad++
    • Privacy Policy
    • About Me
    © 2022 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.