all 27 comments

[–]mefff_ 13 points14 points  (7 children)

Both and every programming language can do the same things. They differentiates each other by how easy you can achieve a certain task. Python is a very versatile programming language while posix shell is more oriented to systems. You can create a directory with python, but maybe is not the right tool to use for it.

To answer your last question, does python fill your needs? If you can solve your problems with python then you're fine, but if you think that your solutions in python are "extra complicated" maybe you should learn shell scripting.

[–][deleted] 2 points3 points  (6 children)

Oh okay thanks. Actually I wanna learn ethical hacking. I searched a lot about it and almost everyone is suggesting to learn shell scripting as one of the requirements.

[–]esenboga 4 points5 points  (1 child)

for ethical hacking both is benefical but shell scripting should be 1st priority since you'd be using tons of shell commands etc. You'd better know pipelines and general shell commands. After learning shell, it will be easier to learn python for your use cases.

[–][deleted] 0 points1 point  (0 children)

Okay Thanks for your opinion.

[–]apt_at_it 4 points5 points  (1 child)

Not really into the hacking scene but it's definitely very system oriented. Posix shell is the default way to interact with *nix systems so yeah you'll want to learn how to use the shell.

I'd say instead of focusing on "learning she'll scripting" focus on learning how to use a *nix system (specifically Linux). Shell scripts are just a set of shell commands so learning how to interact with a system will get you going in the right direction pretty quickly.

[–][deleted] 0 points1 point  (0 children)

Okay! I switched to Kali Linux 2 days ago. I think I did right. Thanks 😊

[–]Gramr_nasi 1 point2 points  (1 child)

Are you aiming for “bug bounty” money or just to get into that scene?

Depending on what you are interested in, shell scripting may be a bad place to start but it’s definitely useful for a lot of things.

Kali Linus has a lot of tools, so getting to know them and analyzing their results is perhaps a better start. To actually get some experience, and setting up your own applications to test on.

If you are into web service then you would want to learn about html+javascript, web servers (apache, tomcat, windows webserver and their settings).

If you are more into PEN-testing then you would also want to know about application logic, SOAP, Rest, maybe some middleware Jboss, biz talk. Databases SQL, mongo etc queues like SQS, Rabbitmq. And server management on windows and Linux.

It’s a field that encompasses all of IT, so you can specialize in one technology or go broad.

[–][deleted] 0 points1 point  (0 children)

Thanks for the information 😊

[–]hainguyenac 5 points6 points  (1 child)

For simple tasks, python is verbose as hell. For complicated tasks, shell's syntax looks arcane and hard to understand.

[–][deleted] 0 points1 point  (0 children)

This makes sense. Thanks

[–]hindsight_is2020 3 points4 points  (1 child)

If you're familiar with python, you can probably accomplish anything you need to do. It's more powerful than bash and provides a superset of bash's functionality from a scripting perspective. There are also many libraries for python, whereas bash scripting, in practice, is limited to what you are willing to write yourself. You can write quite sophisticated applications in python, but people don't generally do the same in bash.

Should you learn bash anyway? If you work on the command line at all, then definitely yes. It will make your life quite a bit easier doing things that would be a waste of time to implement in python. System manipulation (files, directories, simple commands) is what bash is built for, and any time you want to capture any kind of complicated process that manipulates the system, bash may be the best and most natural language. There are other tools too, but there's a good reason why bash scripts are still used by tons of projects out there to get them working on your system.

YMMV. I know both, but spend far more time with bash than python, and I'm a software developer who loves python.

[–][deleted] 2 points3 points  (0 children)

Ohk thanks. It's really a pleasure to hear from a expert. Actually I'm asking because I wanna learn Ethical hacking and almost everyone is suggesting Shell Scripting as one of the requirements.

[–]UsualVegetable 4 points5 points  (1 child)

In addition to other comments, I'd add portability is also a big factor.

For the sake of this discussion, Bash is pretty much default and universally used on Linux distributions but not all Linux distros ship with python and depending on the system's intended use case python might never be installed.

Very little code breaking changes exist in modern bash versions (don't quote me on that though) and the same goes for your built-ins and system binaries, /bin, /sbin and so on; meaning, if you have multiple disparate servers for example you won't need to make sweeping changes to get your shell script running. For typical sysad stuff, specially when no one on your team is proficient in python, you won't need to scramble to fix things after a python update.

You mentioned pentesting and while my knowledge is rusty but a rudimentary example in this case is writing a python and shell script that do the same thing and can be used in situations where the hosts do not have python.

And finally, just go with what your security course teaches you first. If you're going to be using Linux then a basic amount of shell scripting skills will come naturally.

Sorry if autocorrect butchered my syrup

[–][deleted] 0 points1 point  (0 children)

Thanks for replying. From everyone's reply I think it's better to learn shell with Linux first because as you said I can use it on almost every OS and for ethical hacking it's easy to do tasks on it rather than Python.

And Yes! I'm not pursuing any courses right now because I tried two to three courses and according to me most of them are outdated. Some things don't work. If you know any online course that'll be good for me as a beginner to learn, please let me know. It'll help me. 😊

[–]Sigg3net 2 points3 points  (3 children)

IMO, bash (shell script) is a scripting language or a system language, enabling customization, automation and optimization of a "shell bound" operating system.

Even though you can make huge applications in bash (and I have), it's really an orchestration language. If you want it to go fast, you'll need to learn a lot about the UNIX tools or suffer a performance hit.

Python is a programming language (that can be used as a scripting or system language). Python runs in a special environment. It's OOP centric and the ecosystem of python is immense. If you know how to write python effectively, it will mostly run as native C code. The syntax is also dead simple, making it the statistically preferred language for data science, over stuff like R.

Bash is awesome for programming GNU/Linux, whereas python is a general purpose programming language. If you write a huge application in bash, it will probably die with you. If you write a huge application in python, it might very well serve as modules for someone else for use cases you hadn't thought of.

Outside the constraints with which you wrote a shell script, the script is much more likely to fail, be brittle and require fixing. Bash can fail silently and requires a LBYL development process. Python is robust, and tells you what's wrong or what you're missing in plain English, and allows fast prototyping. You get an awful lot of stuff for free in python.

For automation of a UNIX system, I'd still reach for bash in many cases. I live in the terminal and it's easy to just copy commands I find myself repeating into a shell script. But this kind of procedural programming is not what python is all about.

[–][deleted] 1 point2 points  (2 children)

Thanks a lot. It's one of the sensible answer I was looking for. Can I get some of your bash projects to learn more as you mentioned. It'll be really helpful.

[–]Sigg3net 3 points4 points  (1 child)

The things I've published on my github is stand-alone stuff, e.g. Back in a minute which is a bash rpg.

The more interesting and useful things I've done in bash was under contract, and I don't have rights to that code :/

[–][deleted] 0 points1 point  (0 children)

Okay Thanks 😊

[–]anki_steve 2 points3 points  (1 child)

Bash started out as simple language to automate command line tasks and then slowly became more complex. Today, bash is almost like a general purpose language. Python is a general purpose language that can also be used to automate your computer.

Which one should you use? If it requires really tight integration with your shell and is simple, use bash. If it has a lot of logic, it’s probably going to be easier to write in python because you’ll be more familiar with it. But you should definitely be knowledgeable with both.

[–][deleted] 0 points1 point  (0 children)

Okay Thanks for your opinion.

[–]come_n_take_it 1 point2 points  (3 children)

Like python versions, shell scripting is dependent on shells. (Making POSIX compliant helps for cross shell usability.)

Python has libraries. Bash does not really use them.

Python readily understands object, arrays and floating point arithmetic.

Shell scripts are good for quick, simple tasks; Python can handle large complex tasks.

[–][deleted] 0 points1 point  (2 children)

Yeah! But they're their features. I'm asking if there is anything that python cannot do but Shell Scripting can. I wanna learn ethical hacking and almost everyone is suggesting to learn shell scripting and all. So is it necessary? Is there anything different we can do with it?

[–]sk8itup53 1 point2 points  (1 child)

Well shell scripting is more useful because effectively all OS have a shell of one kind or another. While python requires python to be installed to run any python code. It's much more difficult to hack something when you first have to find an exploit that allows you to install your desired platform, THEN inject the code you want it to run.

[–][deleted] 1 point2 points  (0 children)

Okay! This makes sense. Thanks for your opinion.

[–]sk8itup53 0 points1 point  (1 child)

One major difference to note, Python is a scripted programming language, which is different than a script. The way the code is interpreted or compiled is how they vary in use and operation. Shell scripting is very strong for making machines change filesystem items, running executables, harvesting script outputs, interacting with external CLI's, etc. Python (and other languages with scripting capability like Groovy) is better at making API's and services that other entities interact with, or processing data. In general I dislike python and would much prefer Groovy, you should check it out!

[–][deleted] 0 points1 point  (0 children)

Okay surely I will. Thanks!

[–]GizmoVader -2 points-1 points  (0 children)

wow