A short Lesson Learned: Copying Files in Linux

A short Lesson Learned: Copying Files in Linux

Recently, while transferring the necessary files from my development computer to a production server. I ran into an issue. Now the simplicity of the issue is what I believe makes this worth sharing. If at least one person who reads this snippet finds it useful, then I will consider my job done.

While developing my personal portfolio www.devdotlog.com , I ran into a weird issue. After publishing my first version of the website, I realized I had made a terrible mistake. In my original design, I did not spend enough time sorting out how I would like the website to respond to mobile devices. So I resolved to fix that, after a few lines of code and a lot of thinking. I managed to add the mobile responsiveness I needed.

I had my server ready, my ssh keys were exchanged. So what’s next, well let’s transfer the files to /var/www/html

So I copy my development directory using the * wildcard character. In reality, I used the scp command but to keep things simple let’s use cp

cp ~/development/* /var/www/html

I meticulously typed in the address to my website. It pops up, great it’s working. My happiness is short lived, when I resized the browser window to test the response of the website, I see nothing. Silence….

I cat the contents of my style.css file on the server and it matches line by line what’s on my development computer. How can this be ? What happened?

Whenever you copy files using the * card character. It copies all files except for hidden files. So if my dev directory had two files in it called .hidden nothidden.txt , only the nothidden.txt would have been copied. This of course wrecked havoc with my configurations files.

In order to copy both hidden and non-hidden files use . The syntax would look as follows

cp ~/development/. /var/www/html

Nothing fancy, but easy to miss.