DEV Community

Discussion on: Intro To Linux [For Beginners]

Collapse
 
kailyons profile image
Loralighte

As a Linux user for 2 years, I am glad to say I left the Windows ecosystem. Now my use cases for my computer isn't the same for everyone else, but I can safely say my life has improved when switching to Linux. I actually cannot switch back to Windows 10, as there is a severe learning curve that is bigger than getting into Linux when I was a Windows 10 user. I appreciate this article, but some tidbits. First, amazing choice picking Ubuntu as the recommendation. 2nd, in CHMOD, when wanting to do quick changes to a file it is easily all you need to do is chmod +/-<permission_char> so to give something like my ever-so-lovely sass.sh file permissions to execute it is chmod +x sass.sh, and to remove said permission is chmod -x sass.sh. With updating and installing software, another tidbit, apt-get is being replaced for apt, which is the same game different name. Another tidbit, to copy directories, do cp -r origDirectory newDirectory! I have also learned with that same cp -r trick, you can do it to the directory you are in by doing cp -r . newDirectory, the dot is one of the most useful tools in Linux. Lastly, the tilda. Always remember the tilda (~) means your HOME directory. Meaning if you do rm ~/random-file for example, it will delete /home/thisuser/randomfile, will make life a heck of a lot easier.

Collapse
 
knav2013 profile image
knav2013

Does cp -r preserve directory timestamp or does it restamp with current date/time? Using GUI didn't preserve (was using Ubuntu 16.04.8 lxde desktop). Now I've started using tar to compress then extract with preserve timestamps switch

Collapse
 
kailyons profile image
Loralighte

That is a question I do not know the answer to

Thread Thread
 
knav2013 profile image
knav2013 • Edited

A unix and linux forum had the answer (unix.stackexchange.com/questions/4...

cp -r --preserve=timestamps SOURCE DESTINATION

No need to tar compress then tar extract with preserve time stamp switch.

I tested the above 'cp -r --preserve=timestamps SOURCE DESTINATION' command and it works like a dream.

Thread Thread
 
pgronkievitz profile image
Patryk Gronkiewicz

You also can use rsync

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️ • Edited

I just tried it out and no, apparently it doesn't.

EDIT: man cp and a quick search for timestamp reveals that when copy is called with the -p option, it should preserve timestamps. Not sure if this is a GNU thing though, but even busybox seems to support his flag.

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Name checks out

Collapse
 
ishandeveloper profile image
Ishan Sharma • Edited

Thank you, man! Really appreciate your suggestions.

After reading your comment, I really felt that I hadn't done proper justice to the chmod command, and made it somewhat fearful for new users to try out. I have made a few changes to the post, regarding the same.